postgresql/src/backend/storage
Michael Paquier 78c24e97dd Fix concurrency issues with WAL segment recycling on Windows
This commit is mostly a revert of aaa3aed, that switched the routine
doing the internal renaming of recycled WAL segments to use on Windows a
combination of CreateHardLinkA() plus unlink() instead of rename().  As
reported by several users of Postgres 13, this is causing concurrency
issues when manipulating WAL segments, mostly in the shape of the
following error:
LOG:  could not rename file "pg_wal/000000XX000000YY000000ZZ":
Permission denied

This moves back to a logic where a single rename() (well, pgrename() for
Windows) is used.  This issue has proved to be hard to hit when I tested
it, facing it only once with an archive_command that was not able to do
its work, so it is environment-sensitive.  The reporters of this issue
have been able to confirm that the situation improved once we switched
back to a single rename().  In order to check things, I have provided to
the reporters a patched build based on 13.2 with aaa3aed reverted, to
test if the error goes away, and an unpatched build of 13.2 to test if
the error still showed up (just to make sure that I did not mess up my
build process).

Extra thanks to Fujii Masao for pointing out what looked like the
culprit commit, and to all the reporters for taking the time to test
what I have sent them.

Reported-by: Andrus, Guy Burgess, Yaroslav Pashinsky, Thomas Trenz
Reviewed-by: Tom Lane, Andres Freund
Discussion: https://postgr.es/m/3861ff1e-0923-7838-e826-094cc9bef737@hot.ee
Discussion: https://postgr.es/m/16874-c3eecd319e36a2bf@postgresql.org
Discussion: https://postgr.es/m/095ccf8d-7f58-d928-427c-b17ace23cae6@burgess.co.nz
Discussion: https://postgr.es/m/16927-67c570d968c99567%40postgresql.org
Discussion: https://postgr.es/m/YFBcRbnBiPdGZvfW@paquier.xyz
Backpatch-through: 13
2021-03-22 14:02:36 +09:00
..
buffer Extend PageIsVerified() to handle more custom options 2020-11-02 10:41:23 +09:00
file Fix concurrency issues with WAL segment recycling on Windows 2021-03-22 14:02:36 +09:00
freespace Initial pgindent and pgperltidy run for v13. 2020-05-14 13:06:50 -04:00
ipc Hold interrupts while running dsm_detach() callbacks. 2021-02-15 14:20:42 +13:00
large_object Remove utils/acl.h from catalog/objectaddress.h 2020-03-10 10:27:00 +01:00
lmgr Fix CREATE INDEX CONCURRENTLY for simultaneous prepared transactions. 2021-01-30 00:00:42 -08:00
page Extend PageIsVerified() to handle more custom options 2020-11-02 10:41:23 +09:00
smgr Free disk space for dropped relations on commit. 2020-12-01 13:22:01 +13:00
sync Use correct and consistent unit abbreviation 2020-06-01 21:18:36 +02:00
Makefile Refactor the fsync queue for wider use. 2019-04-04 23:38:38 +13:00