v20240805-0002-use-GetFakeLSNForUnloggedRel.patch
text/x-patch
Filename: v20240805-0002-use-GetFakeLSNForUnloggedRel.patch
Type: text/x-patch
Part: 1
Message:
Re: WIP: parallel GiST index builds
Patch
Format: format-patch
Series: patch v20240805-0002
Subject: use GetFakeLSNForUnloggedRel
| File | + | − |
|---|---|---|
| src/backend/access/gist/gist.c | 5 | 5 |
| src/backend/access/gist/gistutil.c | 3 | 7 |
| src/backend/access/gist/gistvacuum.c | 3 | 3 |
| src/include/access/gist_private.h | 1 | 1 |
From 92401b291bfd87a2b7db6de53fbc9d9689916039 Mon Sep 17 00:00:00 2001
From: Tomas Vondra <tomas@vondra.me>
Date: Mon, 29 Jul 2024 18:03:44 +0200
Subject: [PATCH v20240805 2/6] use GetFakeLSNForUnloggedRel
---
src/backend/access/gist/gist.c | 10 +++++-----
src/backend/access/gist/gistutil.c | 10 +++-------
src/backend/access/gist/gistvacuum.c | 6 +++---
src/include/access/gist_private.h | 2 +-
4 files changed, 12 insertions(+), 16 deletions(-)
diff --git a/src/backend/access/gist/gist.c b/src/backend/access/gist/gist.c
index f5f56fb2503..21c87c8c12f 100644
--- a/src/backend/access/gist/gist.c
+++ b/src/backend/access/gist/gist.c
@@ -509,7 +509,7 @@ gistplacetopage(Relation rel, Size freespace, GISTSTATE *giststate,
if (is_build)
{
if (is_parallel)
- recptr = gistGetFakeLSN(rel, is_parallel);
+ recptr = GetFakeLSNForUnloggedRel();
else
recptr = GistBuildLSN;
}
@@ -520,7 +520,7 @@ gistplacetopage(Relation rel, Size freespace, GISTSTATE *giststate,
dist, oldrlink, oldnsn, leftchildbuf,
markfollowright);
else
- recptr = gistGetFakeLSN(rel, false);
+ recptr = gistGetFakeLSN(rel);
}
for (ptr = dist; ptr; ptr = ptr->next)
@@ -581,7 +581,7 @@ gistplacetopage(Relation rel, Size freespace, GISTSTATE *giststate,
if (is_build)
{
if (is_parallel)
- recptr = gistGetFakeLSN(rel, is_parallel);
+ recptr = GetFakeLSNForUnloggedRel();
else
recptr = GistBuildLSN;
}
@@ -603,7 +603,7 @@ gistplacetopage(Relation rel, Size freespace, GISTSTATE *giststate,
leftchildbuf);
}
else
- recptr = gistGetFakeLSN(rel, false);
+ recptr = gistGetFakeLSN(rel);
}
PageSetLSN(page, recptr);
@@ -1739,7 +1739,7 @@ gistprunepage(Relation rel, Page page, Buffer buffer, Relation heapRel)
PageSetLSN(page, recptr);
}
else
- PageSetLSN(page, gistGetFakeLSN(rel, false));
+ PageSetLSN(page, gistGetFakeLSN(rel));
END_CRIT_SECTION();
}
diff --git a/src/backend/access/gist/gistutil.c b/src/backend/access/gist/gistutil.c
index 733d5849317..78e98d68b15 100644
--- a/src/backend/access/gist/gistutil.c
+++ b/src/backend/access/gist/gistutil.c
@@ -1012,7 +1012,7 @@ gistproperty(Oid index_oid, int attno,
* purpose.
*/
XLogRecPtr
-gistGetFakeLSN(Relation rel, bool is_parallel)
+gistGetFakeLSN(Relation rel)
{
if (rel->rd_rel->relpersistence == RELPERSISTENCE_TEMP)
{
@@ -1035,12 +1035,8 @@ gistGetFakeLSN(Relation rel, bool is_parallel)
static XLogRecPtr lastlsn = InvalidXLogRecPtr;
XLogRecPtr currlsn = GetXLogInsertRecPtr();
- /*
- * Shouldn't be called for WAL-logging relations, but parallell
- * builds are an exception - we need the fake LSN to detect
- * concurrent changes.
- */
- Assert(is_parallel || !RelationNeedsWAL(rel));
+ /* Shouldn't be called for WAL-logging relations */
+ Assert(!RelationNeedsWAL(rel));
/* No need for an actual record if we already have a distinct LSN */
if (!XLogRecPtrIsInvalid(lastlsn) && lastlsn == currlsn)
diff --git a/src/backend/access/gist/gistvacuum.c b/src/backend/access/gist/gistvacuum.c
index 082804e9c7d..24fb94f473e 100644
--- a/src/backend/access/gist/gistvacuum.c
+++ b/src/backend/access/gist/gistvacuum.c
@@ -181,7 +181,7 @@ gistvacuumscan(IndexVacuumInfo *info, IndexBulkDeleteResult *stats,
if (RelationNeedsWAL(rel))
vstate.startNSN = GetInsertRecPtr();
else
- vstate.startNSN = gistGetFakeLSN(rel, false);
+ vstate.startNSN = gistGetFakeLSN(rel);
/*
* The outer loop iterates over all index pages, in physical order (we
@@ -376,7 +376,7 @@ restart:
PageSetLSN(page, recptr);
}
else
- PageSetLSN(page, gistGetFakeLSN(rel, false));
+ PageSetLSN(page, gistGetFakeLSN(rel));
END_CRIT_SECTION();
@@ -664,7 +664,7 @@ gistdeletepage(IndexVacuumInfo *info, IndexBulkDeleteResult *stats,
if (RelationNeedsWAL(info->index))
recptr = gistXLogPageDelete(leafBuffer, txid, parentBuffer, downlink);
else
- recptr = gistGetFakeLSN(info->index, false);
+ recptr = gistGetFakeLSN(info->index);
PageSetLSN(parentPage, recptr);
PageSetLSN(leafPage, recptr);
diff --git a/src/include/access/gist_private.h b/src/include/access/gist_private.h
index d5b22bc1018..1aeb35cdcb7 100644
--- a/src/include/access/gist_private.h
+++ b/src/include/access/gist_private.h
@@ -535,7 +535,7 @@ extern void gistMakeUnionKey(GISTSTATE *giststate, int attno,
GISTENTRY *entry2, bool isnull2,
Datum *dst, bool *dstisnull);
-extern XLogRecPtr gistGetFakeLSN(Relation rel, bool is_parallel);
+extern XLogRecPtr gistGetFakeLSN(Relation rel);
/* gistvacuum.c */
extern IndexBulkDeleteResult *gistbulkdelete(IndexVacuumInfo *info,
--
2.45.2