aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlvaro Herrera <alvherre@alvh.no-ip.org>2017-08-15 13:35:12 -0300
committerAlvaro Herrera <alvherre@alvh.no-ip.org>2017-08-15 13:35:12 -0300
commitd9a622cee162775ae42aa5c1ac592760d0d777d9 (patch)
treec18a9b7d062691d0798a98f4ace267cad01c7441
parente139f1953f29db245f60a7acb72fccb1e05d2442 (diff)
downloadpostgresql-d9a622cee162775ae42aa5c1ac592760d0d777d9.tar.gz
postgresql-d9a622cee162775ae42aa5c1ac592760d0d777d9.zip
Fix error handling path in autovacuum launcher
The original code (since 00e6a16d01) 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
-rw-r--r--src/backend/postmaster/autovacuum.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/backend/postmaster/autovacuum.c b/src/backend/postmaster/autovacuum.c
index 00b1e823af4..e1019ce3957 100644
--- a/src/backend/postmaster/autovacuum.c
+++ b/src/backend/postmaster/autovacuum.c
@@ -91,6 +91,7 @@
#include "storage/proc.h"
#include "storage/procsignal.h"
#include "storage/sinvaladt.h"
+#include "storage/smgr.h"
#include "tcop/tcopprot.h"
#include "utils/dsa.h"
#include "utils/fmgroids.h"
@@ -525,6 +526,26 @@ AutoVacLauncherMain(int argc, char *argv[])
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
* next time.
*/