Rethink PROCSIGNAL_BARRIER_SMGRRELEASE.
authorThomas Munro <[email protected]>
Sat, 7 May 2022 04:19:42 +0000 (16:19 +1200)
committerThomas Munro <[email protected]>
Sat, 7 May 2022 04:32:10 +0000 (16:32 +1200)
commitb74e94dc27fdbb13954f230b1d1298430afa6c0c
treee67f872e3a7ce3cd62480978831c541529d36e45
parent701d918a426b394620ce4d046533f77262c70829
Rethink PROCSIGNAL_BARRIER_SMGRRELEASE.

With sufficiently bad luck, it was possible for IssuePendingWritebacks()
to reopen a file after we'd processed PROCSIGNAL_BARRIER_SMGRRELEASE and
before the file was unlinked by some other backend.  That left a small
hole in commit 4eb21763's plan to fix all spurious errors from DROP
TABLESPACE and similar on Windows.

Fix by closing md.c's segments, instead of just closing fd.c's
descriptors, and then teaching smgrwriteback() not to open files that
aren't already open.

Reported-by: Andres Freund <[email protected]>
Reviewed-by: Robert Haas <[email protected]>
Discussion: https://postgr.es/m/20220209220004.kb3dgtn2x2k2gtdm%40alap3.anarazel.de
src/backend/storage/smgr/md.c
src/backend/storage/smgr/smgr.c
src/include/storage/md.h
src/include/storage/smgr.h