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
This commit is contained in:
Narek Galstyan
2024-06-10 21:16:32 -07:00
committed by GitHub
parent 0eceaa3966
commit 9dcf1bdc80

View File

@@ -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);
}