Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit d9a622c

Browse files
committed
Fix error handling path in autovacuum launcher
The original code (since 00e6a16) 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
1 parent e139f19 commit d9a622c

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/backend/postmaster/autovacuum.c

+21
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@
9191
#include "storage/proc.h"
9292
#include "storage/procsignal.h"
9393
#include "storage/sinvaladt.h"
94+
#include "storage/smgr.h"
9495
#include "tcop/tcopprot.h"
9596
#include "utils/dsa.h"
9697
#include "utils/fmgroids.h"
@@ -524,6 +525,26 @@ AutoVacLauncherMain(int argc, char *argv[])
524525
/* Abort the current transaction in order to recover */
525526
AbortCurrentTransaction();
526527

528+
/*
529+
* Release any other resources, for the case where we were not in a
530+
* transaction.
531+
*/
532+
LWLockReleaseAll();
533+
pgstat_report_wait_end();
534+
AbortBufferIO();
535+
UnlockBuffers();
536+
if (CurrentResourceOwner)
537+
{
538+
ResourceOwnerRelease(CurrentResourceOwner,
539+
RESOURCE_RELEASE_BEFORE_LOCKS,
540+
false, true);
541+
/* we needn't bother with the other ResourceOwnerRelease phases */
542+
}
543+
AtEOXact_Buffers(false);
544+
AtEOXact_SMgr();
545+
AtEOXact_Files();
546+
AtEOXact_HashTables(false);
547+
527548
/*
528549
* Now return to normal top-level context and clear ErrorContext for
529550
* next time.

0 commit comments

Comments
 (0)