diff --git a/CHANGELOG.md b/CHANGELOG.md index 34af92e..bf81eb0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.6.2 (unreleased) + +- Reduced lock contention with parallel HNSW index builds + ## 0.6.1 (2024-03-04) - Fixed error with `ANALYZE` and vectors with different dimensions diff --git a/src/hnswbuild.c b/src/hnswbuild.c index 990fb7f..b5a72ab 100644 --- a/src/hnswbuild.c +++ b/src/hnswbuild.c @@ -437,8 +437,8 @@ InsertTupleInMemory(HnswBuildState * buildstate, HnswElement element) char *base = buildstate->hnswarea; /* Wait if another process needs exclusive lock */ - LWLockAcquire(entryWaitLock, LW_EXCLUSIVE); - LWLockRelease(entryWaitLock); + if (LWLockAcquireOrWait(entryWaitLock, LW_EXCLUSIVE)) + LWLockRelease(entryWaitLock); /* Get entry point */ LWLockAcquire(entryLock, LW_SHARED);