Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 3c6a268

Browse files
committed
Setting synchronous_commit to local in data subs apply workers.
With old 'on' value deadlocks arise since we wait for all transactions, as quickly discovered by Kostya.
1 parent 1ac27b7 commit 3c6a268

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

shard.sql

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,9 +399,13 @@ BEGIN
399399
-- Create subscription for new data channel
400400
-- It should never exist at this moment, but just in case...
401401
PERFORM shardman.eliminate_sub(lname);
402+
-- It is important to set synchronous_commit to local in apply
403+
-- worker. Otherwise deadlocks arise because currently in sync replication
404+
-- PG waits for any transaction remote commit regardless of which relations
405+
-- it touches.
402406
EXECUTE format(
403407
'CREATE SUBSCRIPTION %I connection %L
404-
PUBLICATION %I with (create_slot = false, slot_name = %L, copy_data = false, synchronous_commit = on);',
408+
PUBLICATION %I with (create_slot = false, slot_name = %L, copy_data = false, synchronous_commit = local);',
405409
lname, oldtail_connstr, lname, lname);
406410
END $$ LANGUAGE plpgsql;
407411

0 commit comments

Comments
 (0)