Skip to content

Commit 46e69b4

Browse files
authored
Ensure accurate backgroundIndexing status in debugInfo (#811)
convert updateJobMutex to mutable check backgroundIndexing under the lock
1 parent cea54c9 commit 46e69b4

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/VecSim/algorithms/svs/svs_tiered.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ class TieredSVSIndex : public VecSimTieredIndex<DataType, float> {
227227
std::atomic_flag indexUpdateScheduled = ATOMIC_FLAG_INIT;
228228
// Used to prevent running multiple index update jobs in parallel.
229229
// Even if update jobs scheduled sequentially, they can be started in parallel.
230-
std::mutex updateJobMutex;
230+
mutable std::mutex updateJobMutex;
231231

232232
// The reason of following container just to properly destroy jobs which not executed yet
233233
SVSMultiThreadJob::JobsRegistry uncompletedJobs;
@@ -880,6 +880,8 @@ class TieredSVSIndex : public VecSimTieredIndex<DataType, float> {
880880
.indexUpdateScheduled =
881881
static_cast<bool>(this->indexUpdateScheduled.test())};
882882
info.tieredInfo.specificTieredBackendInfo.svsTieredInfo = svsTieredInfo;
883+
// prevent parallel updates
884+
std::lock_guard<std::mutex> lock(this->updateJobMutex);
883885
info.tieredInfo.backgroundIndexing =
884886
svsTieredInfo.indexUpdateScheduled && info.tieredInfo.frontendCommonInfo.indexSize > 0
885887
? VecSimBool_TRUE

0 commit comments

Comments
 (0)