pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Grigory Smolkin <g.smolkin@postgrespro.ru>
To: pgsql-bugs@lists.postgresql.org
Subject: Re: logical replication: could not create file "state.tmp": File exists
Date: Mon, 2 Dec 2019 15:27:48 +0300
Message-ID: <6ea8cf93-ca74-ceb0-18bc-4fc5f8f55df1@postgrespro.ru> (raw)
In-Reply-To: <20191202043547.GE1696@paquier.xyz>
References: <08bbfab1-a61d-3750-fc18-4ab2c1aa7f09@postgrespro.ru>
	<20191202043547.GE1696@paquier.xyz>


On 12/2/19 7:35 AM, Michael Paquier wrote:
> 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.

Hello!

I didn`t see the very first error that left behind the temp file.
I`ve requested it just now, but it will take some time to get it (there 
are several terabytes of text log).
But I assume that it was out of space error, which, by the look of the 
code, should produce ERROR and leave temp file behind, just as it 
happened in aforementioned  case.


>
>> 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.

I`m sorry, but it was an production system, so, as I understand it, 
stale temp file was hastily deleted without long considerations.

Thank you for your interest in this topic.

>
> Have others thoughts or objections to share?
> --
> Michael

-- 
Grigory Smolkin
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company






view thread (11+ messages)  latest in thread

Message-ID: <6ea8cf93-ca74-ceb0-18bc-4fc5f8f55df1@postgrespro.ru>
Permalink:  ../6ea8cf93-ca74-ceb0-18bc-4fc5f8f55df1@postgrespro.ru/
Also on:    postgresql.org/message-id/6ea8cf93-ca74-ceb0-18bc-4fc5f8f55df1@postgrespro.ru

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: g.smolkin@postgrespro.ru, pgsql-bugs@lists.postgresql.org
  Subject: Re: logical replication: could not create file "state.tmp": File exists
  In-Reply-To: <6ea8cf93-ca74-ceb0-18bc-4fc5f8f55df1@postgrespro.ru>

* 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