• Vladislav Vaintroub's avatar
    MDEV-21551 Fix calculation of current concurrency level in · c20bf8fd
    Vladislav Vaintroub authored
    maybe_wake_or_create_thread()
    
    A task that is executed,could be counted as waiting (after wait_begin()
    before wait_end()) or as long-running (callback runs for a long time).
    
    If task is both marked waiting and long running, then calculation of
    current concurrency (# of executing tasks - # of long tasks - #of waiting tasks)
    is wrong, as task is counted twice.
    
    Thus current concurrency could go negative, but with unsigned arithmetic
    it will become a huge number.
    
    As a result, maybe_wake_or_create_thread() would neither wake or create
    a thread, when it should. Which may result in a deadlock.
    c20bf8fd
tpool_generic.cc 19.5 KB