postgresql/src/backend
Andres Freund dfbaed4597 Use a fd opened for read/write when syncing slots during startup.
Some operating systems, including the reporter's windows, return EBADFD
or similar when fsync() is invoked on a O_RDONLY file descriptor.
Unfortunately RestoreSlotFromDisk() does exactly that; which causes
failures after restarts in at least some scenarios.

If you hit the bug the error message will be something like
ERROR: could not fsync file "pg_replslot/$name/state": Bad file descriptor

Simply use O_RDWR instead of O_RDONLY when opening the relevant file
descriptor to fix the bug.  Unfortunately I have no way of verifying the
fix, but we've seen similar problems in the past.

This bug goes back to 9.4 where slots were introduced. Backpatch
accordingly.

Reported-By: Patrice Drolet
Bug: #13143:
Discussion: 20150424101006.2556.60897@wrigleys.postgresql.org
2015-04-28 00:17:43 +02:00
..
access Fix various typos and grammar errors in comments. 2015-04-26 18:42:31 +02:00
bootstrap Change many routines to return ObjectAddress rather than OID 2015-03-03 14:10:50 -03:00
catalog Fix various typos and grammar errors in comments. 2015-04-26 18:42:31 +02:00
commands Fix various typos and grammar errors in comments. 2015-04-26 18:42:31 +02:00
executor Fix various typos and grammar errors in comments. 2015-04-26 18:42:31 +02:00
foreign Update copyright for 2015 2015-01-06 11:43:47 -05:00
lib Fix a bug in pairing heap removal code. 2015-02-17 22:55:53 +02:00
libpq Also correct therefor to therefore. 2015-04-26 19:05:39 +02:00
main Don't require users of src/port/gettimeofday.c to initialize it. 2015-02-21 12:17:04 -05:00
nodes Add transforms feature 2015-04-26 10:33:14 -04:00
optimizer Improve qual pushdown for RLS and SB views 2015-04-27 12:29:42 -04:00
parser Add transforms feature 2015-04-26 10:33:14 -04:00
po Translation updates 2015-02-01 23:23:40 -05:00
port Remove the option to service interrupts during PGSemaphoreLock(). 2015-02-03 23:25:00 +01:00
postmaster Fix various typos and grammar errors in comments. 2015-04-26 18:42:31 +02:00
regex Replace a bunch more uses of strncpy() with safer coding. 2015-01-24 13:05:42 -05:00
replication Use a fd opened for read/write when syncing slots during startup. 2015-04-28 00:17:43 +02:00
rewrite Perform RLS WITH CHECK before constraints, etc 2015-04-24 20:34:26 -04:00
snowball Update copyright for 2015 2015-01-06 11:43:47 -05:00
storage Fix various typos and grammar errors in comments. 2015-04-26 18:42:31 +02:00
tcop Add transforms feature 2015-04-26 10:33:14 -04:00
tsearch Define integer limits independently from the system definitions. 2015-04-02 17:43:35 +02:00
utils Fix various typos and grammar errors in comments. 2015-04-26 18:42:31 +02:00
.gitignore Add gitignore for mingw/cygwin build outputs 2011-06-09 18:11:47 +02:00
Makefile Update copyright for 2015 2015-01-06 11:43:47 -05:00
common.mk Remove maintainer-check target, fold into normal build 2013-10-10 20:11:56 -04:00
nls.mk Translation updates 2015-02-01 23:23:40 -05:00