lucasfang commented on code in PR #233:
URL: https://github.com/apache/paimon-cpp/pull/233#discussion_r3860925650


##########
src/paimon/common/executor/executor.cpp:
##########
@@ -66,21 +69,22 @@ uint32_t DefaultExecutor::GetThreadNum() const {
 
 void DefaultExecutor::ShutdownInternal(bool wait_for_pending_tasks) {
     {
-        std::unique_lock<std::mutex> lock(queue_mutex_);
-        if (stop_) {
-            return;
-        }
-        stop_ = true;
+        std::unique_lock<std::mutex> lock(state_->mutex);
+        state_->stop = true;

Review Comment:
   ShutdownInternal() dropped the early return that previously made shutdown 
idempotent:
   if (stop_) {
       return;
   }
   Without it, two threads can both observe worker.joinable() == true and call 
join() on the same std::thread. That is a data race on the thread object, and 
in practice the second pthread_join() blocks forever on an already-reaped 
thread id.I reproduced this against the real build by adding a temporary probe 
test (4-thread executor, two threads calling ShutdownNow() concurrently, 50 
iterations).



-- 
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]

Reply via email to