Skip to content

Commit fbfc835

Browse files
committed
Flush logical mapping files with fd opened for read/write at checkpoint
The file descriptor was opened with read-only to fsync a regular file, which would cause EBADFD errors on some platforms. This is similar to the recent fix done by a586cc4 (which was broken by me with 82a5649), except that I noticed this issue while monitoring the backend code for similar mistakes. Backpatch to 9.4, as this has been introduced since logical decoding exists as of b89e151. Author: Michael Paquier Reviewed-by: Andres Freund Discussion: https://postgr.es/m/20191006045548.GA14532@paquier.xyz Backpatch-through: 9.4
1 parent 5136dcf commit fbfc835

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/backend/access/heap/rewriteheap.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1279,7 +1279,8 @@ CheckPointLogicalRewriteHeap(void)
12791279
}
12801280
else
12811281
{
1282-
int fd = OpenTransientFile(path, O_RDONLY | PG_BINARY, 0);
1282+
/* on some operating systems fsyncing a file requires O_RDWR */
1283+
int fd = OpenTransientFile(path, O_RDWR | PG_BINARY, 0);
12831284

12841285
/*
12851286
* The file cannot vanish due to concurrency since this function

0 commit comments

Comments
 (0)