From d4dd73d9704a83000d140634ce0a4d94269215f7 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Tue, 23 Jun 2026 11:39:16 -0700 Subject: [PATCH] Moved repair confirmation after lock wait to catch more potential issues --- src/hnswvacuum.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/hnswvacuum.c b/src/hnswvacuum.c index 40e8588..334e974 100644 --- a/src/hnswvacuum.c +++ b/src/hnswvacuum.c @@ -584,16 +584,18 @@ MarkDeleted(HnswVacuumState * vacuumstate) BufferAccessStrategy bas = vacuumstate->bas; /* - * Wait for index scans and inserts to complete. Scans and inserts before - * this point may contain tuples about to be deleted. Scans and inserts + * Wait for inserts and index scans to complete. Inserts and scans before + * this point may visit tuples about to be deleted. Inserts and scans * after this point will not, since the graph has been repaired. */ - LockPage(index, HNSW_SCAN_LOCK, ExclusiveLock); - UnlockPage(index, HNSW_SCAN_LOCK, ExclusiveLock); - LockPage(index, HNSW_UPDATE_LOCK, ExclusiveLock); UnlockPage(index, HNSW_UPDATE_LOCK, ExclusiveLock); + ConfirmRepaired(vacuumstate); + + LockPage(index, HNSW_SCAN_LOCK, ExclusiveLock); + UnlockPage(index, HNSW_SCAN_LOCK, ExclusiveLock); + while (BlockNumberIsValid(blkno)) { Buffer buf; @@ -770,10 +772,7 @@ hnswbulkdelete(IndexVacuumInfo *info, IndexBulkDeleteResult *stats, /* Pass 2: Repair graph */ HnswBench("RepairGraph", RepairGraph(&vacuumstate)); - /* Pass 3: Confirm repaired */ - HnswBench("ConfirmRepaired", ConfirmRepaired(&vacuumstate)); - - /* Pass 4: Mark as deleted */ + /* Passes 3 and 4: Confirm repaired and mark as deleted */ HnswBench("MarkDeleted", MarkDeleted(&vacuumstate)); FreeVacuumState(&vacuumstate);