mirror of
https://github.com/neondatabase/neon.git
synced 2026-05-22 15:41:15 +00:00
79 lines
2.1 KiB
Diff
79 lines
2.1 KiB
Diff
From 0b0194a57bd0f3598bd57dbedd0df3932330169d Mon Sep 17 00:00:00 2001
|
|
From: Heikki Linnakangas <heikki.linnakangas@iki.fi>
|
|
Date: Fri, 2 Feb 2024 22:26:45 +0200
|
|
Subject: [PATCH 1/1] Make v0.6.0 work with Neon
|
|
|
|
Now that the WAL-logging happens as a separate step at the end of the
|
|
build, we need a few neon-specific hints to make it work.
|
|
---
|
|
src/hnswbuild.c | 36 ++++++++++++++++++++++++++++++++++++
|
|
1 file changed, 36 insertions(+)
|
|
|
|
diff --git a/src/hnswbuild.c b/src/hnswbuild.c
|
|
index 680789b..ec54dea 100644
|
|
--- a/src/hnswbuild.c
|
|
+++ b/src/hnswbuild.c
|
|
@@ -840,9 +840,17 @@ HnswParallelBuildMain(dsm_segment *seg, shm_toc *toc)
|
|
|
|
hnswarea = shm_toc_lookup(toc, PARALLEL_KEY_HNSW_AREA, false);
|
|
|
|
+#ifdef NEON_SMGR
|
|
+ smgr_start_unlogged_build(RelationGetSmgr(indexRel));
|
|
+#endif
|
|
+
|
|
/* Perform inserts */
|
|
HnswParallelScanAndInsert(heapRel, indexRel, hnswshared, hnswarea, false);
|
|
|
|
+#ifdef NEON_SMGR
|
|
+ smgr_finish_unlogged_build_phase_1(RelationGetSmgr(indexRel));
|
|
+#endif
|
|
+
|
|
/* Close relations within worker */
|
|
index_close(indexRel, indexLockmode);
|
|
table_close(heapRel, heapLockmode);
|
|
@@ -1089,13 +1097,41 @@ BuildIndex(Relation heap, Relation index, IndexInfo *indexInfo,
|
|
SeedRandom(42);
|
|
#endif
|
|
|
|
+#ifdef NEON_SMGR
|
|
+ smgr_start_unlogged_build(RelationGetSmgr(index));
|
|
+#endif
|
|
+
|
|
InitBuildState(buildstate, heap, index, indexInfo, forkNum);
|
|
|
|
BuildGraph(buildstate, forkNum);
|
|
|
|
+#ifdef NEON_SMGR
|
|
+ smgr_finish_unlogged_build_phase_1(RelationGetSmgr(index));
|
|
+#endif
|
|
+
|
|
if (RelationNeedsWAL(index))
|
|
+ {
|
|
log_newpage_range(index, forkNum, 0, RelationGetNumberOfBlocks(index), true);
|
|
|
|
+#ifdef NEON_SMGR
|
|
+ {
|
|
+#if PG_VERSION_NUM >= 160000
|
|
+ RelFileLocator rlocator = RelationGetSmgr(index)->smgr_rlocator.locator;
|
|
+#else
|
|
+ RelFileNode rlocator = RelationGetSmgr(index)->smgr_rnode.node;
|
|
+#endif
|
|
+
|
|
+ SetLastWrittenLSNForBlockRange(XactLastRecEnd, rlocator,
|
|
+ MAIN_FORKNUM, 0, RelationGetNumberOfBlocks(index));
|
|
+ SetLastWrittenLSNForRelation(XactLastRecEnd, rlocator, MAIN_FORKNUM);
|
|
+ }
|
|
+#endif
|
|
+ }
|
|
+
|
|
+#ifdef NEON_SMGR
|
|
+ smgr_end_unlogged_build(RelationGetSmgr(index));
|
|
+#endif
|
|
+
|
|
FreeBuildState(buildstate);
|
|
}
|
|
|
|
--
|
|
2.39.2
|
|
|