From 529f37175b860cb247576bd578bb2ecc7744231a Mon Sep 17 00:00:00 2001 From: Zhang Jinrui Date: Mon, 27 Apr 2026 10:15:32 +0000 Subject: [PATCH] Fix CREATE INDEX CONCURRENTLY crash on ivfflat with assertion-enabled PostgreSQL by passing anyvisible=false in ivfflat SampleRows --- src/ivfbuild.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/ivfbuild.c b/src/ivfbuild.c index 78d278e..4604fb5 100644 --- a/src/ivfbuild.c +++ b/src/ivfbuild.c @@ -145,8 +145,14 @@ SampleRows(IvfflatBuildState * buildstate) { BlockNumber targblock = BlockSampler_Next(&buildstate->bs); + /* + * anyvisible must be false when the scan uses an MVCC snapshot + * (i.e. CREATE INDEX CONCURRENTLY), otherwise PG will assert in + * heapam_index_build_range_scan. Always pass false here, matching + * what table_index_build_scan does internally. + */ table_index_build_range_scan(buildstate->heap, buildstate->index, buildstate->indexInfo, - false, true, false, targblock, 1, SampleCallback, (void *) buildstate, NULL); + false, false, false, targblock, 1, SampleCallback, (void *) buildstate, NULL); } /* Normalize if needed */