mirror of
https://github.com/postgres/postgres.git
synced 2025-07-30 11:03:19 +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:
@ -873,6 +873,8 @@ ParallelApplyWorkerMain(Datum main_arg)
|
||||
int worker_slot = DatumGetInt32(main_arg);
|
||||
char originname[NAMEDATALEN];
|
||||
|
||||
InitializingApplyWorker = true;
|
||||
|
||||
/* Setup signal handling. */
|
||||
pqsignal(SIGHUP, SignalHandlerForConfigReload);
|
||||
pqsignal(SIGINT, SignalHandlerForShutdownRequest);
|
||||
@ -940,6 +942,8 @@ ParallelApplyWorkerMain(Datum main_arg)
|
||||
|
||||
InitializeApplyWorker();
|
||||
|
||||
InitializingApplyWorker = false;
|
||||
|
||||
/* Setup replication origin tracking. */
|
||||
StartTransactionCommand();
|
||||
ReplicationOriginNameForLogicalRep(MySubscription->oid, InvalidOid,
|
||||
|
Reference in New Issue
Block a user