From 2ee755d802d052069b8ed647d7fbad23e99181a0 Mon Sep 17 00:00:00 2001 From: meiravgri Date: Sun, 26 Oct 2025 14:26:11 +0000 Subject: [PATCH] convert updateJobMutex to mutable check backgroundIndexing under the lock --- src/VecSim/algorithms/svs/svs_tiered.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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