aboutsummaryrefslogtreecommitdiff
path: root/src/backend/replication/logical/tablesync.c
diff options
context:
space:
mode:
authorAmit Kapila <akapila@postgresql.org>2021-03-17 08:15:12 +0530
committerAmit Kapila <akapila@postgresql.org>2021-03-17 08:15:12 +0530
commit6b67d72b604cb913e39324b81b61ab194d94cba0 (patch)
tree5598da9e3883eb09c338bba27e210fadd5db8bf9 /src/backend/replication/logical/tablesync.c
parent7efeb214ad832fa96ea950d0906b1d2b96316d15 (diff)
downloadpostgresql-6b67d72b604cb913e39324b81b61ab194d94cba0.tar.gz
postgresql-6b67d72b604cb913e39324b81b61ab194d94cba0.zip
Fix race condition in drop subscription's handling of tablesync slots.
Commit ce0fdbfe97 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
Diffstat (limited to 'src/backend/replication/logical/tablesync.c')
-rw-r--r--src/backend/replication/logical/tablesync.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/backend/replication/logical/tablesync.c b/src/backend/replication/logical/tablesync.c
index feb634e7ac0..6ed31812abc 100644
--- a/src/backend/replication/logical/tablesync.c
+++ b/src/backend/replication/logical/tablesync.c
@@ -1051,9 +1051,16 @@ LogicalRepSyncTableStart(XLogRecPtr *origin_startpos)
* Create a new permanent logical decoding slot. This slot will be used
* for the catchup phase after COPY is done, so tell it to use the
* snapshot to make the final data consistent.
+ *
+ * Prevent cancel/die interrupts while creating slot here because it is
+ * possible that before the server finishes this command, a concurrent
+ * drop subscription happens which would complete without removing this
+ * slot leading to a dangling slot on the server.
*/
+ HOLD_INTERRUPTS();
walrcv_create_slot(wrconn, slotname, false /* permanent */ ,
CRS_USE_SNAPSHOT, origin_startpos);
+ RESUME_INTERRUPTS();
/*
* Setup replication origin tracking. The purpose of doing this before the