pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andres Freund <andres@anarazel.de>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Use a fd opened for read/write when syncing slots during startup
Date: Fri, 04 Oct 2019 20:44:21 +0000
Message-ID: <E1iGUR3-0000w4-K0@gemulon.postgresql.org> (raw)

Use a fd opened for read/write when syncing slots during startup, take 2.

Cribbing from dfbaed45975:
    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 this fix was undone in 82a5649fb9db. Re-apply, and add a
comment.

Bug: 16039
Reported-By: Hans Buschmann
Author: Andres Freund
Discussion: https://postgr.es/m/16039-196fc97cc05e141c@postgresql.org
Backpatch: 12-, as 82a5649fb9db

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/a586cc4b6c568e88a459f1a69ac82aa42af7e5ba

Modified Files
--------------
src/backend/replication/slot.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)



view thread (4+ messages)  latest in thread

Message-ID: <E1iGUR3-0000w4-K0@gemulon.postgresql.org>
Permalink:  ../E1iGUR3-0000w4-K0@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1iGUR3-0000w4-K0@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: andres@anarazel.de
  Subject: Re: pgsql: Use a fd opened for read/write when syncing slots during startup
  In-Reply-To: <E1iGUR3-0000w4-K0@gemulon.postgresql.org>
  References: <E1iGUR3-0000w4-K0@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox