aboutsummaryrefslogtreecommitdiff
path: root/src/backend/jit/llvm/llvmjit.c
diff options
context:
space:
mode:
authorMichael Paquier <michael@paquier.xyz>2024-10-01 15:44:03 +0900
committerMichael Paquier <michael@paquier.xyz>2024-10-01 15:44:03 +0900
commitcf4401fe6cf56811343edcad29c96086c2c66481 (patch)
treec492a8e8e0efe3e6dd53e24fe5874d16bb425ed5 /src/backend/jit/llvm/llvmjit.c
parent3b1a377defcfc01d8a3f964e39aa652766ffc188 (diff)
downloadpostgresql-cf4401fe6cf56811343edcad29c96086c2c66481.tar.gz
postgresql-cf4401fe6cf56811343edcad29c96086c2c66481.zip
Fix race condition in COMMIT PREPARED causing orphaned 2PC files
COMMIT PREPARED removes on-disk 2PC files near its end, but the state checked if a file is on-disk or not gets read from shared memory while not holding the two-phase state lock. Because of that, there was a small window where a second backend doing a PREPARE TRANSACTION could reuse the GlobalTransaction put back into the 2PC free list by the COMMIT PREPARED, overwriting the "ondisk" flag read afterwards by the COMMIT PREPARED to decide if its on-disk two-phase state file should be removed, preventing the file deletion. This commit fixes this issue so as the "ondisk" flag in the GlobalTransaction is read while holding the two-phase state lock, not from shared memory after its entry has been added to the free list. Orphaned two-phase state files flushed to disk after a checkpoint are discarded at the beginning of recovery. However, a truncation of pg_xact/ would make the startup process issue a FATAL when it cannot read the SLRU page holding the state of the transaction whose 2PC file was orphaned, which is a necessary step to decide if the 2PC file should be removed or not. Removing manually the file would be necessary in this case. Issue introduced by effe7d9552dd, so backpatch all the way down. Mea culpa. Author: wuchengwen Discussion: https://postgr.es/m/tencent_A7F059B5136A359625C7B2E4A386B3C3F007@qq.com Backpatch-through: 12
Diffstat (limited to 'src/backend/jit/llvm/llvmjit.c')
0 files changed, 0 insertions, 0 deletions