mirror of
https://github.com/postgres/postgres.git
synced 2025-10-19 15:49:24 +03:00
Fix assertion failure in apply worker.
During exit, the logical replication apply worker tries to release session level locks, if any. However, if the apply worker exits due to an error before its connection is initialized, trying to release locks can lead to assertion failure. The locks will be acquired once the worker is initialized, so we don't need to release them till the worker initialization is complete. Reported-by: Alexander Lakhin Author: Hou Zhijie based on inputs from Sawada Masahiko and Amit Kapila Reviewed-by: Amit Kapila Discussion: https://postgr.es/m/2185d65f-5aae-3efa-c48f-fb42b173ef5c@gmail.com
This commit is contained in:
@@ -331,6 +331,9 @@ static TransactionId stream_xid = InvalidTransactionId;
|
||||
*/
|
||||
static uint32 parallel_stream_nchanges = 0;
|
||||
|
||||
/* Are we initializing a apply worker? */
|
||||
bool InitializingApplyWorker = false;
|
||||
|
||||
/*
|
||||
* We enable skipping all data modification changes (INSERT, UPDATE, etc.) for
|
||||
* the subscription if the remote transaction's finish LSN matches the subskiplsn.
|
||||
@@ -4526,6 +4529,8 @@ ApplyWorkerMain(Datum main_arg)
|
||||
WalRcvStreamOptions options;
|
||||
int server_version;
|
||||
|
||||
InitializingApplyWorker = true;
|
||||
|
||||
/* Attach to slot */
|
||||
logicalrep_worker_attach(worker_slot);
|
||||
|
||||
@@ -4548,6 +4553,8 @@ ApplyWorkerMain(Datum main_arg)
|
||||
|
||||
InitializeApplyWorker();
|
||||
|
||||
InitializingApplyWorker = false;
|
||||
|
||||
/* Connect to the origin and start the replication. */
|
||||
elog(DEBUG1, "connecting to publisher using connection string \"%s\"",
|
||||
MySubscription->conninfo);
|
||||
|
Reference in New Issue
Block a user