Yifan Zhang has posted comments on this change. ( http://gerrit.cloudera.org:8080/18867 )
Change subject: [threadpool] Fix unsafe behaviour when SchedulerThread shutdown ...................................................................... Patch Set 16: (3 comments) http://gerrit.cloudera.org:8080/#/c/18867/16//COMMIT_MSG Commit Message: http://gerrit.cloudera.org:8080/#/c/18867/16//COMMIT_MSG@9 PS16, Line 9: When shutdown thread pool with SchedulerThread, thread pool's variable : 'scheduler_' is deleted and set to nullptr, at the same time, : if thread pool token is not shutdown and schedule a task, Since the ThreadPoolToken is created after ThreadPool is created, when we need to shut down a ThreadPool, we should shut down ThreadPoolToken first, right? So I think callers should be restricted from calling ThreadPoolToken::Schedule() after shutting down the thread pool. http://gerrit.cloudera.org:8080/#/c/18867/16/src/kudu/util/threadpool.h File src/kudu/util/threadpool.h: http://gerrit.cloudera.org:8080/#/c/18867/16/src/kudu/util/threadpool.h@612 PS16, Line 612: SchedulerThread* scheduler_; Can the 'scheduler' be a unique_ptr so we don't need to explicitly delete it? Seems it is owned by the ThreadPool. If not, could you document why it must be a raw pointer? http://gerrit.cloudera.org:8080/#/c/18867/16/src/kudu/util/threadpool.cc File src/kudu/util/threadpool.cc: http://gerrit.cloudera.org:8080/#/c/18867/16/src/kudu/util/threadpool.cc@263 PS16, Line 263: { : MutexLock unique_lock(pool_->lock_); : if (PREDICT_FALSE(!MaySubmitNewTasks())) { : return Status::ServiceUnavailable("Thread pool token was shut down"); : } : } nit: Maybe we can move this check into ThreadPool::Schedule? -- To view, visit http://gerrit.cloudera.org:8080/18867 To unsubscribe, visit http://gerrit.cloudera.org:8080/settings Gerrit-Project: kudu Gerrit-Branch: master Gerrit-MessageType: comment Gerrit-Change-Id: I021422f7e51e1007c5bdbc877ab445f70ba12357 Gerrit-Change-Number: 18867 Gerrit-PatchSet: 16 Gerrit-Owner: Yuqi Du <[email protected]> Gerrit-Reviewer: Alexey Serbin <[email protected]> Gerrit-Reviewer: Kudu Jenkins (120) Gerrit-Reviewer: Tidy Bot (241) Gerrit-Reviewer: Yifan Zhang <[email protected]> Gerrit-Reviewer: Yingchun Lai <[email protected]> Gerrit-Reviewer: Yuqi Du <[email protected]> Gerrit-Comment-Date: Mon, 26 Sep 2022 09:35:31 +0000 Gerrit-HasComments: Yes
