diff --git a/src/VecSim/algorithms/svs/svs_tiered.h b/src/VecSim/algorithms/svs/svs_tiered.h index 9da3760b3..a8fb8594b 100644 --- a/src/VecSim/algorithms/svs/svs_tiered.h +++ b/src/VecSim/algorithms/svs/svs_tiered.h @@ -227,7 +227,7 @@ class TieredSVSIndex : public VecSimTieredIndex { std::atomic_flag indexUpdateScheduled = ATOMIC_FLAG_INIT; // Used to prevent running multiple index update jobs in parallel. // Even if update jobs scheduled sequentially, they can be started in parallel. - std::mutex updateJobMutex; + mutable std::mutex updateJobMutex; // The reason of following container just to properly destroy jobs which not executed yet SVSMultiThreadJob::JobsRegistry uncompletedJobs; @@ -880,6 +880,8 @@ class TieredSVSIndex : public VecSimTieredIndex { .indexUpdateScheduled = static_cast(this->indexUpdateScheduled.test())}; info.tieredInfo.specificTieredBackendInfo.svsTieredInfo = svsTieredInfo; + // prevent parallel updates + std::lock_guard lock(this->updateJobMutex); info.tieredInfo.backgroundIndexing = svsTieredInfo.indexUpdateScheduled && info.tieredInfo.frontendCommonInfo.indexSize > 0 ? VecSimBool_TRUE