Skip to content

Commit 20442cf

Browse files
committed
Fix snapshot handling bug in recent BRIN fix
Commit a95e3d8 added ActiveSnapshot push+pop when processing work-items (BRIN autosummarization), but forgot to handle the case of a transaction failing during the run, which drops the snapshot untimely. Fix by making the pop conditional on an element being actually there. Author: Álvaro Herrera <alvherre@kurilemu.de> Backpatch-through: 13 Discussion: https://postgr.es/m/202511041648.nofajnuddmwk@alvherre.pgsql
1 parent b81489d commit 20442cf

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/backend/postmaster/autovacuum.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2682,7 +2682,8 @@ do_autovacuum(void)
26822682

26832683
PushActiveSnapshot(GetTransactionSnapshot());
26842684
perform_work_item(workitem);
2685-
PopActiveSnapshot();
2685+
if (ActiveSnapshotSet()) /* transaction could have aborted */
2686+
PopActiveSnapshot();
26862687

26872688
/*
26882689
* Check for config changes before acquiring lock for further jobs.

0 commit comments

Comments
 (0)