From: Alexander Korotkov Date: Sat, 6 Apr 2024 21:32:46 +0000 (+0300) Subject: Call WaitLSNCleanup() in AbortTransaction() X-Git-Tag: REL_17_BETA1~371 X-Git-Url: http://git.postgresql.org/gitweb/?a=commitdiff_plain;h=74eaf66f988c868deb0816bae4dd184eedae1448;p=postgresql.git Call WaitLSNCleanup() in AbortTransaction() Even though waiting for replay LSN happens without explicit transaction, AbortTransaction() is responsible for the cleanup of the shared memory if the error is thrown in a stored procedure. So, we need to do WaitLSNCleanup() there to clean up after some unexpected error happened while waiting for replay LSN. Discussion: https://postgr.es/m/202404051815.eri4u5q6oj26%40alvherre.pgsql Author: Alvaro Herrera --- diff --git a/src/backend/access/transam/xact.c b/src/backend/access/transam/xact.c index df5a67e4c31..19777b68956 100644 --- a/src/backend/access/transam/xact.c +++ b/src/backend/access/transam/xact.c @@ -38,6 +38,7 @@ #include "commands/async.h" #include "commands/tablecmds.h" #include "commands/trigger.h" +#include "commands/waitlsn.h" #include "common/pg_prng.h" #include "executor/spi.h" #include "libpq/be-fsstubs.h" @@ -2771,6 +2772,11 @@ AbortTransaction(void) */ LWLockReleaseAll(); + /* + * Cleanup waiting for LSN if any. + */ + WaitLSNCleanup(); + /* Clear wait information and command progress indicator */ pgstat_report_wait_end(); pgstat_progress_end_command();