From 1d5c6b6eab3720060902d38c6f7937cfa44e2d65 Mon Sep 17 00:00:00 2001 From: JackyWoo Date: Mon, 23 Oct 2023 23:32:19 +0800 Subject: [PATCH] Fix data race for request processor --- src/Service/RequestProcessor.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Service/RequestProcessor.cpp b/src/Service/RequestProcessor.cpp index 9b869a5900..49590ef918 100644 --- a/src/Service/RequestProcessor.cpp +++ b/src/Service/RequestProcessor.cpp @@ -50,7 +50,11 @@ void RequestProcessor::run() return; size_t committed_request_size = committed_queue.size(); - size_t error_request_size = error_request_ids.size(); + size_t error_request_size; + { + std::unique_lock lk(mutex); + error_request_size = error_request_ids.size(); + } /// 1. process read request, multi thread for (RunnerId runner_id = 0; runner_id < runner_count; runner_id++)