Skip to content
  • Marc Alff's avatar
    a3428e63
    BUG#21841412 SIG 11 IN __STRNCMP_SSE42 AT LIBC.SO.6 · a3428e63
    Marc Alff authored
    Before this fix, the following query:
      SELECT * FROM performance_schema.status_by_account
    could crash the server under load.
    
    The root cause is that the monitoring query inspects
    all running sessions (THD) in the server,
    and reads data (without any locks) from members of THD while the session
    itself is running, creating race conditions.
    
    In particular, while the THD object itself is guaranteed
    to exist in memory, members of THD that contains pointers
    to other memory fragments, such as
      THD::m_main_security_context::m_user::m_ptr
    may change while the session represented by THD is running.
    Reading these members directly is not safe,
    and caused crashes in pfs_visitor.cc, in:
    - match_host()
    - match_user()
    - match_account()
    
    The fix is to abandon inspecting THD::m_main_security_context,
    and inspect instead attributes of PFS_thread to find out if a
    given THD belongs to a given account / user / host.
    
    To achieve this, it is necessary to find the PSI_thread associated
    with a THD.
    
    This relation existed in the code already,
    with member THD::scheduler:m_psi.
    
    The performance schema instrumentation stored in the thread scheduler
    has been moved into THD directly (THD::m_psi), to make the relationship
    usable independently of the thread scheduler.
    
    Note that THD::m_psi is now maintained using atomic operations,
    which allows to safely read THD::m_psi of a running THD session
    from a monitoring query executing
      SELECT * FROM performance_schema.status_by_account
    a3428e63
    BUG#21841412 SIG 11 IN __STRNCMP_SSE42 AT LIBC.SO.6
    Marc Alff authored
    Before this fix, the following query:
      SELECT * FROM performance_schema.status_by_account
    could crash the server under load.
    
    The root cause is that the monitoring query inspects
    all running sessions (THD) in the server,
    and reads data (without any locks) from members of THD while the session
    itself is running, creating race conditions.
    
    In particular, while the THD object itself is guaranteed
    to exist in memory, members of THD that contains pointers
    to other memory fragments, such as
      THD::m_main_security_context::m_user::m_ptr
    may change while the session represented by THD is running.
    Reading these members directly is not safe,
    and caused crashes in pfs_visitor.cc, in:
    - match_host()
    - match_user()
    - match_account()
    
    The fix is to abandon inspecting THD::m_main_security_context,
    and inspect instead attributes of PFS_thread to find out if a
    given THD belongs to a given account / user / host.
    
    To achieve this, it is necessary to find the PSI_thread associated
    with a THD.
    
    This relation existed in the code already,
    with member THD::scheduler:m_psi.
    
    The performance schema instrumentation stored in the thread scheduler
    has been moved into THD directly (THD::m_psi), to make the relationship
    usable independently of the thread scheduler.
    
    Note that THD::m_psi is now maintained using atomic operations,
    which allows to safely read THD::m_psi of a running THD session
    from a monitoring query executing
      SELECT * FROM performance_schema.status_by_account
Loading