• sjaakola's avatar
    MDEV-16005 sporadic failures with galera tests MW-328B and MW-328C · 2f0b8f3e
    sjaakola authored
    These test can sporadically show mutex deadlock warnings between LOCK_wsrep_thd
    and LOCK_thd_data mutexes. This means that these mutexes can be locked in opposite
    order by different threads, and thus result in deadlock situation.
    To fix such issue, the locking policy of these mutexes should be revised and
    enforced to be uniform. However, a quick code review shows that the number of
    lock/unlock operations for these mutexes combined is between 100-200, and all these
    mutex invocations should be checked/fixed.
    
    On the other hand, it turns out that LOCK_wsrep_thd is used for protecting access to
    wsrep variables of THD (wsrep_conflict_state, wsrep_query_state), whereas LOCK_thd_data
    protects query, db and mysys_var variables in THD. Extending LOCK_thd_data to protect
    also wsrep variables looks like a viable solution, as there should not be a use case
    where separate threads need simultaneous access to wsrep variables and THD data variables.
    
    In this commit LOCK_wsrep_thd mutex is refactored to be replaced by LOCK_thd_data.
    By bluntly replacing LOCK_wsrep_thd by LOCK_thd_data, will result in double locking
    of LOCK_thd_data, and some adjustements have been performed to fix such situations.
    2f0b8f3e
sql_class.h 179 KB