Copilot commented on code in PR #61684:
URL: https://github.com/apache/doris/pull/61684#discussion_r2982709099


##########
be/src/load/memtable/memtable_flush_executor.cpp:
##########
@@ -222,6 +222,7 @@ void FlushToken::_flush_memtable(std::shared_ptr<MemTable> 
memtable_ptr, int32_t
                                  int64_t submit_task_time) {
     signal::set_signal_task_id(_rowset_writer->load_id());
     signal::tablet_id = memtable_ptr->tablet_id();
+    _stats.flush_running_count++;

Review Comment:
   `flush_running_count` is incremented without holding `_mutex`, while the 
deferred decrement is performed under `_mutex`. This creates a data-race risk 
and can still lead to inconsistent observations (including transient negative 
values) under concurrent reads/writes. Consider protecting the increment with 
the same `_mutex` (or making `flush_running_count` an atomic and using 
consistent memory ordering) so the counter updates are thread-safe and 
consistently synchronized.
   ```suggestion
       {
           std::lock_guard<std::mutex> lock(_mutex);
           _stats.flush_running_count++;
       }
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to