Fix assertion failure in apply worker.
authorAmit Kapila <akapila@postgresql.org>
Wed, 3 May 2023 04:43:13 +0000 (10:13 +0530)
committerAmit Kapila <akapila@postgresql.org>
Wed, 3 May 2023 04:47:49 +0000 (10:17 +0530)
commitde63f8dadee4afa152ce177fd3c562d47373a728
tree0d0dc49ae8ee5dded48eeb1e1594f2ceb2c708f4
parent6489875ce6b16662142bc70e003437b9753c199f
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
src/backend/replication/logical/applyparallelworker.c
src/backend/replication/logical/launcher.c
src/backend/replication/logical/worker.c
src/include/replication/worker_internal.h