Commit d9a622ce authored by Alvaro Herrera's avatar Alvaro Herrera

Fix error handling path in autovacuum launcher

The original code (since 00e6a16d) was assuming aborting the
transaction in autovacuum launcher was sufficient to release all
resources, but in reality the launcher runs quite a lot of code out of
any transactions.  Re-introduce individual cleanup calls to make abort
more robust.

Reported-by: Robert Haas
Discussion: https://postgr.es/m/CA+TgmobQVbz4K_+RSmiM9HeRKpy3vS5xnbkL95gSEnWijzprKQ@mail.gmail.com
parent e139f195
...@@ -91,6 +91,7 @@ ...@@ -91,6 +91,7 @@
#include "storage/proc.h" #include "storage/proc.h"
#include "storage/procsignal.h" #include "storage/procsignal.h"
#include "storage/sinvaladt.h" #include "storage/sinvaladt.h"
#include "storage/smgr.h"
#include "tcop/tcopprot.h" #include "tcop/tcopprot.h"
#include "utils/dsa.h" #include "utils/dsa.h"
#include "utils/fmgroids.h" #include "utils/fmgroids.h"
...@@ -524,6 +525,26 @@ AutoVacLauncherMain(int argc, char *argv[]) ...@@ -524,6 +525,26 @@ AutoVacLauncherMain(int argc, char *argv[])
/* Abort the current transaction in order to recover */ /* Abort the current transaction in order to recover */
AbortCurrentTransaction(); AbortCurrentTransaction();
/*
* Release any other resources, for the case where we were not in a
* transaction.
*/
LWLockReleaseAll();
pgstat_report_wait_end();
AbortBufferIO();
UnlockBuffers();
if (CurrentResourceOwner)
{
ResourceOwnerRelease(CurrentResourceOwner,
RESOURCE_RELEASE_BEFORE_LOCKS,
false, true);
/* we needn't bother with the other ResourceOwnerRelease phases */
}
AtEOXact_Buffers(false);
AtEOXact_SMgr();
AtEOXact_Files();
AtEOXact_HashTables(false);
/* /*
* Now return to normal top-level context and clear ErrorContext for * Now return to normal top-level context and clear ErrorContext for
* next time. * next time.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment