Skip to content

Commit 8733f0b

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 640c590 commit 8733f0b

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
@@ -2544,7 +2544,8 @@ do_autovacuum(void)
25442544

25452545
PushActiveSnapshot(GetTransactionSnapshot());
25462546
perform_work_item(workitem);
2547-
PopActiveSnapshot();
2547+
if (ActiveSnapshotSet()) /* transaction could have aborted */
2548+
PopActiveSnapshot();
25482549

25492550
/*
25502551
* Check for config changes before acquiring lock for further jobs.

0 commit comments

Comments
 (0)