pgvector.git / summary / log / commit / refs
commit 9dcf1bdc80094097b1c8a795ef67b8e1cd6b9e50
Author: Narek Galstyan <ngalstyan4@gmail.com>
Commit: GitHub <noreply@github.com>
Date: Tue Jun 11 04:16:32 2024 +0000
Fix init_fork WAL-logging on unlogged indexes (#591)
Currently pgvector does not create any WAL records for unlogged tables
Postgres assumes INIT_FORK of unlogged tables is persistent and uses it
to reset the table index to its default empty state after a server
crash.
This patch makes INIT_FORK of unlogged table WAL-tracked, which ensures
an unlogged table is usable after a crash-restart
src/hnswbuild.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/hnswbuild.c b/src/hnswbuild.c
index ee94ed92..dcfb2bdd 100644
--- a/src/hnswbuild.c
+++ b/src/hnswbuild.c
@@ -1121,8 +1121,8 @@ BuildIndex(Relation heap, Relation index, IndexInfo *indexInfo,
BuildGraph(buildstate, forkNum);
- if (RelationNeedsWAL(index))
- log_newpage_range(index, forkNum, 0, RelationGetNumberOfBlocks(index), true);
+ if (RelationNeedsWAL(index) || forkNum == INIT_FORKNUM)
+ log_newpage_range(index, forkNum, 0, RelationGetNumberOfBlocksInFork(index, forkNum), true);
FreeBuildState(buildstate);
}
[parent: 0eceaa39662b]