wasphin commented on PR #3683:
URL: https://github.com/apache/brpc/pull/3683#issuecomment-6498580362

   One compatibility edge case with changing the default `bthread_concurrency` 
from 9 (`8 + BTHREAD_EPOLL_THREAD_NUM`) to 8: an application using 
`--task_group_ntags=9`, with otherwise default concurrency settings, can now 
hang during scheduler initialization.
   
   `TaskControl::init()` assigns the initial workers to tags using `i % 
FLAGS_task_group_ntags`, then waits for every tag to have at least one 
registered `TaskGroup`. With eight initial workers, only tags 0–7 are 
populated, so the wait for tag 8 never completes. Reserved workers cannot fill 
the gap because `bthread_add_reserved_concurrency_by_tag()` first calls 
`get_or_new_task_control()`, which must finish initialization before adding 
them.
   
   To clarify the scope: the initialization defect already exists whenever the 
initial worker count is smaller than the tag count. This PR does not introduce 
that waiting logic; lowering the default exposes the existing defect for a 
previously working nine-tag configuration. The all-default configuration (one 
tag) is unaffected. Equality is sufficient: the requirement is 
`task_group_ntags <= initial worker count`, where the initial count comes from 
`bthread_min_concurrency` when lazy growth is enabled, otherwise from 
`bthread_concurrency`.
   
   Could initialization ensure that every tag gets an initial worker, or reject 
an insufficient initial count before entering the wait loop? A regression test 
for the nine-tag/default-concurrency case would cover this transition.
   
   This finding is based on static inspection; I have not run a reproducer.
   


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