From 40b5e6b1344c09e93990a9d7db47b1f7cb68c491 Mon Sep 17 00:00:00 2001 From: sparknack Date: Tue, 4 Nov 2025 14:25:33 +0800 Subject: [PATCH] fix: avoid potential race conditions when updating the executor (#45230) issue: #43040 Signed-off-by: Shawn Wang --- internal/core/src/storage/FileWriter.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/internal/core/src/storage/FileWriter.h b/internal/core/src/storage/FileWriter.h index d3556bc6b5..72c68c2e75 100644 --- a/internal/core/src/storage/FileWriter.h +++ b/internal/core/src/storage/FileWriter.h @@ -359,15 +359,16 @@ class FileWriteWorkerPool { bool AddTask(std::function task) { + std::lock_guard lock(executor_mutex_); if (executor_ == nullptr) { return false; } - std::lock_guard lock(executor_mutex_); executor_->add(std::move(task)); return true; } ~FileWriteWorkerPool() { + std::lock_guard lock(executor_mutex_); if (executor_ != nullptr) { executor_->stop(); executor_->join();