Moved repair confirmation after lock wait to catch more potential issues

This commit is contained in:
Andrew Kane
2026-06-23 11:39:16 -07:00
parent ffe28bb954
commit d4dd73d970

View File

@@ -584,16 +584,18 @@ MarkDeleted(HnswVacuumState * vacuumstate)
BufferAccessStrategy bas = vacuumstate->bas; BufferAccessStrategy bas = vacuumstate->bas;
/* /*
* Wait for index scans and inserts to complete. Scans and inserts before * Wait for inserts and index scans to complete. Inserts and scans before
* this point may contain tuples about to be deleted. Scans and inserts * this point may visit tuples about to be deleted. Inserts and scans
* after this point will not, since the graph has been repaired. * 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); LockPage(index, HNSW_UPDATE_LOCK, ExclusiveLock);
UnlockPage(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)) while (BlockNumberIsValid(blkno))
{ {
Buffer buf; Buffer buf;
@@ -770,10 +772,7 @@ hnswbulkdelete(IndexVacuumInfo *info, IndexBulkDeleteResult *stats,
/* Pass 2: Repair graph */ /* Pass 2: Repair graph */
HnswBench("RepairGraph", RepairGraph(&vacuumstate)); HnswBench("RepairGraph", RepairGraph(&vacuumstate));
/* Pass 3: Confirm repaired */ /* Passes 3 and 4: Confirm repaired and mark as deleted */
HnswBench("ConfirmRepaired", ConfirmRepaired(&vacuumstate));
/* Pass 4: Mark as deleted */
HnswBench("MarkDeleted", MarkDeleted(&vacuumstate)); HnswBench("MarkDeleted", MarkDeleted(&vacuumstate));
FreeVacuumState(&vacuumstate); FreeVacuumState(&vacuumstate);