From: Michael Paquier <michael@paquier.xyz>
To: Grigory Smolkin <g.smolkin@postgrespro.ru>
Cc: Pg Bugs <pgsql-bugs@postgresql.org>
Subject: Re: logical replication: could not create file "state.tmp": File exists
Date: Mon, 2 Dec 2019 13:35:47 +0900
Message-ID: <20191202043547.GE1696@paquier.xyz> (raw)
In-Reply-To: <08bbfab1-a61d-3750-fc18-4ab2c1aa7f09@postgrespro.ru>
References: <08bbfab1-a61d-3750-fc18-4ab2c1aa7f09@postgrespro.ru>
On Sat, Nov 30, 2019 at 03:09:39PM +0300, Grigory Smolkin wrote:
> I`ve digged a bit into this problem, and it`s turned out that in
> SaveSlotToPath() temp file for replication slot is opened with 'O_CREAT |
> O_EXCL' flags, which makes this routine as not very reentrant.
What did you see as I/O problem before facing the actual error
reported here? Was it just ENOSPC, a fsync failure, or just a failure
in closing the fd? The first pattern is mostly what I guess happened,
still a fsync failure would not trigger a PANIC here (actually we
really should do that!), but I am raising a different thread about
that issue.
> Since an exclusive lock is taken before temp file creation, I think it
> should be safe to replace O_EXCL with O_TRUNC.
> Script to reproduce and patch are attached.
Agreed. I prefer the O_TRUNC option because that's less code churn.
Also, as it can still be useful to have a look at the temporary state
file after a crash or a failure, doing unlink() in the error code
paths is no good option IMO.
Have others thoughts or objections to share?
--
Michael
Attachments:
signature.asc (application/pgp-signature, 832B) download
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-bugs@postgresql.org
Cc: michael@paquier.xyz, g.smolkin@postgrespro.ru
Subject: Re: logical replication: could not create file "state.tmp": File exists
In-Reply-To: <20191202043547.GE1696@paquier.xyz>
References: <08bbfab1-a61d-3750-fc18-4ab2c1aa7f09@postgrespro.ru> <20191202043547.GE1696@paquier.xyz>
* 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