aboutsummaryrefslogtreecommitdiff
path: root/src/backend/access/transam/xlog.c
diff options
context:
space:
mode:
authorAmit Kapila <akapila@postgresql.org>2023-12-11 08:50:43 +0530
committerAmit Kapila <akapila@postgresql.org>2023-12-11 08:50:43 +0530
commit8d7d2197f31c1839db4726d1a12cb29016f4fa36 (patch)
tree1ac2182c2336a421f6c1413947c2ab3188ffb864 /src/backend/access/transam/xlog.c
parent90834ceccd7298d4495c088fab85e6d87b9cb086 (diff)
downloadpostgresql-8d7d2197f31c1839db4726d1a12cb29016f4fa36.tar.gz
postgresql-8d7d2197f31c1839db4726d1a12cb29016f4fa36.zip
Fix an undetected deadlock due to apply worker.
The apply worker needs to update the state of the subscription tables to 'READY' during the synchronization phase which requires locking the corresponding subscription. The apply worker also waits for the subscription tables to reach the 'SYNCDONE' state after holding the locks on the subscription and the wait is done using WaitLatch. The 'SYNCDONE' state is changed by tablesync workers again by locking the corresponding subscription. Both the state updates use AccessShareLock mode to lock the subscription, so they can't block each other. However, a backend can simultaneously try to acquire a lock on the same subscription using AccessExclusiveLock mode to alter the subscription. Now, the backend's wait on a lock can sneak in between the apply worker and table sync worker causing deadlock. In other words, apply_worker waits for tablesync worker which waits for backend, and backend waits for apply worker. This is not detected by the deadlock detector because apply worker uses WaitLatch. The fix is to release existing locks in apply worker before it starts to wait for tablesync worker to change the state. Reported-by: Tomas Vondra Author: Shlok Kyal Reviewed-by: Amit Kapila, Peter Smith Backpatch-through: 12 Discussion: https://postgr.es/m/d291bb50-12c4-e8af-2af2-7bb9bb4d8e3e@enterprisedb.com
Diffstat (limited to 'src/backend/access/transam/xlog.c')
0 files changed, 0 insertions, 0 deletions