|
41 | 41 | * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group |
42 | 42 | * Portions Copyright (c) 1994, Regents of the University of California |
43 | 43 | * |
44 | | - * $PostgreSQL: pgsql/src/backend/access/transam/slru.c,v 1.33 2005/12/06 23:08:32 tgl Exp $ |
| 44 | + * $PostgreSQL: pgsql/src/backend/access/transam/slru.c,v 1.34 2006/01/21 04:38:21 tgl Exp $ |
45 | 45 | * |
46 | 46 | *------------------------------------------------------------------------- |
47 | 47 | */ |
@@ -128,7 +128,6 @@ typedef struct SlruFlushData |
128 | 128 | typedef enum |
129 | 129 | { |
130 | 130 | SLRU_OPEN_FAILED, |
131 | | - SLRU_CREATE_FAILED, |
132 | 131 | SLRU_SEEK_FAILED, |
133 | 132 | SLRU_READ_FAILED, |
134 | 133 | SLRU_WRITE_FAILED, |
@@ -652,26 +651,19 @@ SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruFlush fdata) |
652 | 651 | * transactions that have already been truncated from the commit log. |
653 | 652 | * Easiest way to deal with that is to accept references to |
654 | 653 | * nonexistent files here and in SlruPhysicalReadPage.) |
| 654 | + * |
| 655 | + * Note: it is possible for more than one backend to be executing |
| 656 | + * this code simultaneously for different pages of the same file. |
| 657 | + * Hence, don't use O_EXCL or O_TRUNC or anything like that. |
655 | 658 | */ |
656 | 659 | SlruFileName(ctl, path, segno); |
657 | | - fd = BasicOpenFile(path, O_RDWR | PG_BINARY, S_IRUSR | S_IWUSR); |
| 660 | + fd = BasicOpenFile(path, O_RDWR | O_CREAT | PG_BINARY, |
| 661 | + S_IRUSR | S_IWUSR); |
658 | 662 | if (fd < 0) |
659 | 663 | { |
660 | | - if (errno != ENOENT) |
661 | | - { |
662 | | - slru_errcause = SLRU_OPEN_FAILED; |
663 | | - slru_errno = errno; |
664 | | - return false; |
665 | | - } |
666 | | - |
667 | | - fd = BasicOpenFile(path, O_RDWR | O_CREAT | O_EXCL | PG_BINARY, |
668 | | - S_IRUSR | S_IWUSR); |
669 | | - if (fd < 0) |
670 | | - { |
671 | | - slru_errcause = SLRU_CREATE_FAILED; |
672 | | - slru_errno = errno; |
673 | | - return false; |
674 | | - } |
| 664 | + slru_errcause = SLRU_OPEN_FAILED; |
| 665 | + slru_errno = errno; |
| 666 | + return false; |
675 | 667 | } |
676 | 668 |
|
677 | 669 | if (fdata) |
@@ -763,13 +755,6 @@ SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid) |
763 | 755 | errdetail("could not open file \"%s\": %m", |
764 | 756 | path))); |
765 | 757 | break; |
766 | | - case SLRU_CREATE_FAILED: |
767 | | - ereport(ERROR, |
768 | | - (errcode_for_file_access(), |
769 | | - errmsg("could not access status of transaction %u", xid), |
770 | | - errdetail("could not create file \"%s\": %m", |
771 | | - path))); |
772 | | - break; |
773 | 758 | case SLRU_SEEK_FAILED: |
774 | 759 | ereport(ERROR, |
775 | 760 | (errcode_for_file_access(), |
|
0 commit comments