logical replication: could not create file "state.tmp": File exists

From: Grigory Smolkin <g(dot)smolkin(at)postgrespro(dot)ru>
To: Pg Bugs <pgsql-bugs(at)postgresql(dot)org>
Subject: logical replication: could not create file "state.tmp": File exists
Date: 2019-11-30 12:09:39
Message-ID: 08bbfab1-a61d-3750-fc18-4ab2c1aa7f09@postgrespro.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hello!

One of my colleagues encountered an out of space condition, which broke
his logical replication setup.
It`s manifested with the following errors:

ERROR:  could not receive data from WAL stream: ERROR:  could not create
file "pg_replslot/some_sub/state.tmp": File exists

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.

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.

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

Attachment Content-Type Size
replication_bug.sh application/x-shellscript 1.4 KB
0001-logical_replication_fix.patch text/x-patch 543 bytes

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Martin Querleu 2019-11-30 12:46:02 Re: Strange query planner behavior
Previous Message Pavel Stehule 2019-11-30 10:45:59 Re: Strange query planner behavior