postgresql/src
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
..
backend Use a fd opened for read/write when syncing slots during startup. 2015-04-28 00:17:43 +02:00
bin Fix various typos and grammar errors in comments. 2015-04-26 18:42:31 +02:00
common Reorganize our CRC source files again. 2015-04-14 17:03:42 +03:00
include Improve qual pushdown for RLS and SB views 2015-04-27 12:29:42 -04:00
interfaces Fix various typos and grammar errors in comments. 2015-04-26 18:42:31 +02:00
makefiles Don't overwrite EXTRA_INSTALL 2015-04-25 21:00:39 -04:00
pl Add transforms feature 2015-04-26 10:33:14 -04:00
port Fix various typos and grammar errors in comments. 2015-04-26 18:42:31 +02:00
template Remove duplicate specification of -Ae for HP-UX C compiler. 2015-01-13 22:52:11 -05:00
test Improve qual pushdown for RLS and SB views 2015-04-27 12:29:42 -04:00
timezone Update time zone data files to tzdata release 2015a. 2015-01-30 22:45:44 -05:00
tools Fix vcbuild failures and chkpass dependency caused by 854adb8 2015-04-27 10:56:04 -04:00
tutorial Update copyright for 2015 2015-01-06 11:43:47 -05:00
.gitignore Convert cvsignore to gitignore, and add .gitignore for build targets. 2010-09-22 12:57:04 +02:00
DEVELOPERS Replace a couple of references to files that no longer exist in the source 2009-05-04 08:08:47 +00:00
Makefile Create libpgcommon, and move pg_malloc et al to it 2013-02-12 11:21:05 -03:00
Makefile.global.in Fix shell error on Solaris 2015-04-23 13:09:18 -04:00
Makefile.shlib Add transforms feature 2015-04-26 10:33:14 -04:00
bcc32.mak Autoconfiscate selection of 64-bit int type for 64-bit large object API. 2012-10-07 21:52:43 -04:00
nls-global.mk Setup error context callback for transaction lock waits 2014-03-19 15:10:36 -03:00
win32.mak Autoconfiscate selection of 64-bit int type for 64-bit large object API. 2012-10-07 21:52:43 -04:00