Skip to content

Commit 6b67d72

Browse files
author
Amit Kapila
committed
Fix race condition in drop subscription's handling of tablesync slots.
Commit ce0fdbf made tablesync slots permanent and allow Drop Subscription to drop such slots. However, it is possible that before tablesync worker could get the acknowledgment of slot creation, drop subscription stops it and that can lead to a dangling slot on the publisher. Prevent cancel/die interrupts while creating a slot in the tablesync worker. Reported-by: Thomas Munro as per buildfarm Author: Amit Kapila Reviewed-by: Vignesh C, Takamichi Osumi Discussion: https://postgr.es/m/CA+hUKGJG9dWpw1cOQ2nzWU8PHjm=PTraB+KgE5648K9nTfwvxg@mail.gmail.com
1 parent 7efeb21 commit 6b67d72

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/backend/replication/logical/tablesync.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,9 +1051,16 @@ LogicalRepSyncTableStart(XLogRecPtr *origin_startpos)
10511051
* Create a new permanent logical decoding slot. This slot will be used
10521052
* for the catchup phase after COPY is done, so tell it to use the
10531053
* snapshot to make the final data consistent.
1054+
*
1055+
* Prevent cancel/die interrupts while creating slot here because it is
1056+
* possible that before the server finishes this command, a concurrent
1057+
* drop subscription happens which would complete without removing this
1058+
* slot leading to a dangling slot on the server.
10541059
*/
1060+
HOLD_INTERRUPTS();
10551061
walrcv_create_slot(wrconn, slotname, false /* permanent */ ,
10561062
CRS_USE_SNAPSHOT, origin_startpos);
1063+
RESUME_INTERRUPTS();
10571064

10581065
/*
10591066
* Setup replication origin tracking. The purpose of doing this before the

0 commit comments

Comments
 (0)