Re: Replace O_EXCL with O_TRUNC for creation of state.tmp in SaveSlotToPath
Michael Paquier <michael@paquier.xyz>
From: Michael Paquier <michael@paquier.xyz>
To: Kevin K Biju <kevinkbiju@gmail.com>
Cc: pgsql-hackers@lists.postgresql.org
Date: 2025-10-16T01:25:45Z
Lists: pgsql-hackers
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
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
On Wed, Oct 15, 2025 at 07:30:39PM +0530, Kevin K Biju wrote: > Thanks for the context. I missed the earlier discussions about the same > issue. Using unlink in the error paths makes sense to me. There is an edge > case in my mind, in case unlink fails as well, and we end up in the same > condition; however, the chance of that occurring is sufficiently low. My suspicion is that an unlink() failure would link to much more problems, including what could be crashes in critical sections. That would mean a crash, where the state.tmp file would get cleaned up by recovery. What we have now in the tree should be (I hope!) a good balance. That was 6 years ago, and it is very easy to miss, so no worries. Even in my case, I've recalled the previous discussion after one night of sleep, only because I've participated in it and because the automated truncation you have suggested was itching me. Somewhat. > Thanks for the quick response! No problem. -- Michael