Improved locking code

This commit is contained in:
Andrew Kane
2024-01-08 09:05:12 -08:00
parent 520e274dde
commit 62ee33bb92

View File

@@ -432,21 +432,18 @@ BuildCallback(Relation index, CALLBACK_ITEM_POINTER, Datum *values,
return;
/* Flush pages if needed */
HnswLockAcquire(hnswshared);
if (!graph->flushed && graph->memoryUsed >= graph->memoryTotal)
{
HnswLockAcquire(hnswshared);
if (!hnswshared)
ereport(NOTICE,
(errmsg("hnsw graph no longer fits into maintenance_work_mem after " INT64_FORMAT " tuples", (int64) graph->indtuples),
errdetail("Building will take significantly more time."),
errhint("Increase maintenance_work_mem to speed up builds.")));
if (!graph->flushed)
FlushPages(buildstate);
HnswLockRelease(hnswshared);
FlushPages(buildstate);
}
HnswLockRelease(hnswshared);
oldCtx = MemoryContextSwitchTo(buildstate->tmpCtx);