• Sergey Vojtovich's avatar
    Thread safe statistics loading · 609a0d3d
    Sergey Vojtovich authored
    Previously multiple threads were allowed to load statistics concurrently.
    There were no known problems caused by this. But given amount of data
    races in this code, it'd happen sooner or later.
    
    To avoid scalability bottleneck, statistics loading is protected by
    per-TABLE_SHARE atomic variable.
    
    Whenever statistics were loaded by preceding statement (hot-path), a
    scalable load-acquire check is performed.
    
    Whenever statistics have to be loaded anew, mutual exclusion for loaders
    is established by atomic variable. If statistics are being loaded
    concurrently, statement waits until load is completed.
    
    TABLE_STATISTICS_CB::stats_can_be_read and
    TABLE_STATISTICS_CB::stats_is_read are replaced with a tri state atomic
    variable.
    
    Part of MDEV-19061 - table_share used for reading statistical tables is
                         not protected
    609a0d3d
table.h 92.5 KB