Yuqi Du has posted comments on this change. ( 
http://gerrit.cloudera.org:8080/18867 )

Change subject: [threadpool] Fix unsafe behaviour when SchedulerThread shutdown
......................................................................


Patch Set 18:

(1 comment)

http://gerrit.cloudera.org:8080/#/c/18867/18/src/kudu/util/threadpool-test.cc
File src/kudu/util/threadpool-test.cc:

http://gerrit.cloudera.org:8080/#/c/18867/18/src/kudu/util/threadpool-test.cc@224
PS18, Line 224: token->Shutdown();
              :   ASSERT_OK(token->Schedule([&counter]() { SimpleTaskMethod(3, 
&counter); }, delay_ms));
> I'm confused about why we can still use the token schedule tasks while it h
One thread shutdown the 'token' and another thread can do 'token->Schedule'. 
The two lines is a mock scene for that case.


The second question 'Should the Schedule() return IllegalState?'. Yes, it can 
be written like this.
But there is not a very good way to do this to check token' state of shutdown.

MaySubmitNewTasks() can do this, but no lock protect 'state_' in 
ThreadPoolToken  and it uses the pool_'s lock (DoSubmit). we can not use the 
lock as 'DoSubmit' because
In ‘pool_->Scheduler()’? also use the lock again, that's a dead lock. Ignore 
the lock may be ok. state_ RUNNING to shutdown(QUIESCING, QUIESCED), read an 
old value, that's not a serious problem, but it's not reach our intention 
(check the state), we should also deal with the misjudgment.

When token is shutdown and  'token->Scheduler() ' return OK, that's not a 
problem. That means function task is pushed into thread pool's SchedulerThread 
queue, and check by SchedulerThread' logic (token->Submit can check it).



--
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: 18
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: Wed, 21 Dec 2022 13:54:51 +0000
Gerrit-HasComments: Yes

Reply via email to