Clean up properly error_context_stack in autovacuum worker on exception
authorMichael Paquier
Wed, 23 Oct 2019 01:25:50 +0000 (10:25 +0900)
committerMichael Paquier
Wed, 23 Oct 2019 01:25:50 +0000 (10:25 +0900)
Any callback set would have no meaning in the context of an exception.
As an autovacuum worker exits quickly in this context, this could be
only an issue within EmitErrorReport(), where the elog hook is for
example called.  That's unlikely to going to be a problem, but let's be
clean and consistent with other code paths handling exceptions.  This is
present since 2909419, which introduced autovacuum.

Author: Ashwin Agrawal
Reviewed-by: Tom Lane, Michael Paquier
Discussion: https://postgr.es/m/CALfoeisM+_+dgmAdAOHAu0k-ZpEHHqSSG=GRf3pKJGm8OqWX0w@mail.gmail.com
Backpatch-through: 9.4

src/backend/postmaster/autovacuum.c

index 55f43b419ccb0714e6d851c8804dbe609c647a44..2d925d2ee0c33904712206aa4b930c6b67aeb527 100644 (file)
@@ -1571,6 +1571,9 @@ AutoVacWorkerMain(int argc, char *argv[])
     */
    if (sigsetjmp(local_sigjmp_buf, 1) != 0)
    {
+       /* since not using PG_TRY, must reset error stack by hand */
+       error_context_stack = NULL;
+
        /* Prevents interrupts while cleaning up */
        HOLD_INTERRUPTS();