Skip to content

Commit c1793f2

Browse files
committed
In SPGiST replay, do conflict resolution before modifying the page.
In yesterday's commit 962e0cc, I added the ResolveRecoveryConflictWithSnapshot call in the wrong place. I correctly put it before spgRedoVacuumRedirect itself would modify the index page --- but not before RestoreBkpBlocks, so replay of a record with a full-page image would modify the page before kicking off any conflicting HS transactions. Oops.
1 parent 9fb5952 commit c1793f2

File tree

1 file changed

+27
-13
lines changed

1 file changed

+27
-13
lines changed

src/backend/access/spgist/spgxlog.c

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -889,15 +889,6 @@ spgRedoVacuumRedirect(XLogRecPtr lsn, XLogRecord *record)
889889
ptr += sizeof(spgxlogVacuumRedirect);
890890
itemToPlaceholder = (OffsetNumber *) ptr;
891891

892-
/*
893-
* If any redirection tuples are being removed, make sure there are no
894-
* live Hot Standby transactions that might need to see them. This code
895-
* behaves similarly to btree's XLOG_BTREE_REUSE_PAGE case.
896-
*/
897-
if (InHotStandby && TransactionIdIsValid(xldata->newestRedirectXid))
898-
ResolveRecoveryConflictWithSnapshot(xldata->newestRedirectXid,
899-
xldata->node);
900-
901892
if (!(record->xl_info & XLR_BKP_BLOCK_1))
902893
{
903894
buffer = XLogReadBuffer(xldata->node, xldata->blkno, false);
@@ -964,10 +955,33 @@ spg_redo(XLogRecPtr lsn, XLogRecord *record)
964955
MemoryContext oldCxt;
965956

966957
/*
967-
* SP-GiST indexes do not require any conflict processing. NB: If we ever
968-
* implement a similar optimization as we have in b-tree, and remove
969-
* killed tuples outside VACUUM, we'll need to handle that here.
958+
* If we have any conflict processing to do, it must happen before we
959+
* update the page.
970960
*/
961+
if (InHotStandby)
962+
{
963+
switch (info)
964+
{
965+
case XLOG_SPGIST_VACUUM_REDIRECT:
966+
{
967+
spgxlogVacuumRedirect *xldata =
968+
(spgxlogVacuumRedirect *) XLogRecGetData(record);
969+
970+
/*
971+
* If any redirection tuples are being removed, make sure
972+
* there are no live Hot Standby transactions that might
973+
* need to see them.
974+
*/
975+
if (TransactionIdIsValid(xldata->newestRedirectXid))
976+
ResolveRecoveryConflictWithSnapshot(xldata->newestRedirectXid,
977+
xldata->node);
978+
break;
979+
}
980+
default:
981+
break;
982+
}
983+
}
984+
971985
RestoreBkpBlocks(lsn, record, false);
972986

973987
oldCxt = MemoryContextSwitchTo(opCtx);
@@ -1072,7 +1086,7 @@ spg_desc(StringInfo buf, uint8 xl_info, char *rec)
10721086
out_target(buf, ((spgxlogVacuumRedirect *) rec)->node);
10731087
appendStringInfo(buf, "vacuum redirect tuples on page %u, newest XID %u",
10741088
((spgxlogVacuumRedirect *) rec)->blkno,
1075-
((spgxlogVacuumRedirect *) rec)->newestRedirectXid);
1089+
((spgxlogVacuumRedirect *) rec)->newestRedirectXid);
10761090
break;
10771091
default:
10781092
appendStringInfo(buf, "unknown spgist op code %u", info);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy