diff options
author | Michael Paquier <michael@paquier.xyz> | 2019-10-09 13:31:22 +0900 |
---|---|---|
committer | Michael Paquier <michael@paquier.xyz> | 2019-10-09 13:31:22 +0900 |
commit | fbfc835b463af02c70ba19eae8897780ee807055 (patch) | |
tree | f48a052a6a8a57e927a7850ba2823365dc7bc85c | |
parent | 5136dcf6ab21379df899cfdf8db4628bee613ebc (diff) |
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 a586cc4b (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
-rw-r--r-- | src/backend/access/heap/rewriteheap.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/backend/access/heap/rewriteheap.c b/src/backend/access/heap/rewriteheap.c index aca3a96d7e5..f208b5c4aa9 100644 --- a/src/backend/access/heap/rewriteheap.c +++ b/src/backend/access/heap/rewriteheap.c @@ -1279,7 +1279,8 @@ CheckPointLogicalRewriteHeap(void) } else { - int fd = OpenTransientFile(path, O_RDONLY | PG_BINARY, 0); + /* on some operating systems fsyncing a file requires O_RDWR */ + int fd = OpenTransientFile(path, O_RDWR | PG_BINARY, 0); /* * The file cannot vanish due to concurrency since this function |