logical replication: could not create file "state.tmp": File exists
Grigory Smolkin <g.smolkin@postgrespro.ru>
From: Grigory Smolkin <g.smolkin@postgrespro.ru>
To: Pg Bugs <pgsql-bugs@postgresql.org>
Date: 2019-11-30T12:09:39Z
Lists: pgsql-bugs
Attachments
- replication_bug.sh (application/x-shellscript)
- 0001-logical_replication_fix.patch (text/x-patch) patch 0001
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
Commits
-
Remove state.tmp when failing to save a replication slot
- c878d9808420 13.23 landed
- f57f2760e665 14.20 landed
- 0adf424b490b 15.15 landed
- bfdd1a12d2d9 16.11 landed
- 42348839d8b7 17.7 landed
- 9a6ea00ac8c0 18.1 landed
- 912af1c7e9c9 19 (unreleased) landed