• Marko Mäkelä's avatar
    MDEV-19614 SET GLOBAL innodb_ deadlock due to LOCK_global_system_variables · 626f2a1c
    Marko Mäkelä authored
    The update callback functions for several settable global InnoDB variables
    are acquiring InnoDB latches while holding LOCK_global_system_variables.
    
    On the other hand, some InnoDB code is invoking THDVAR() while holding
    InnoDB latches. An example of this is thd_lock_wait_timeout() that is
    called by lock_rec_enqueue_waiting(). In some cases, the
    intern_sys_var_ptr() that is invoked by THDVAR() may acquire
    LOCK_global_system_variables, via sync_dynamic_session_variables().
    
    In lock_rec_enqueue_waiting(), we really must be holding some InnoDB
    latch while invoking THDVAR(). This implies that
    LOCK_global_system_variables must conceptually reside below any InnoDB
    latch in the latching order. That in turns implies that the various
    update callback functions must release LOCK_global_system_variables
    before acquiring any InnoDB mutexes or rw-locks, and reacquire
    LOCK_global_system_variables later. The validate functions are being
    invoked while not holding LOCK_global_system_variables and thus they
    do not need any changes.
    
    The following statements are affected by this:
    
    SET GLOBAL innodb_adaptive_hash_index = …;
    SET GLOBAL innodb_cmp_per_index_enabled = 1;
    SET GLOBAL innodb_old_blocks_pct = …;
    SET GLOBAL innodb_fil_make_page_dirty_debug = …; -- debug builds only
    SET GLOBAL innodb_buffer_pool_evict = uncompressed; -- debug builds only
    SET GLOBAL innodb_purge_run_now = 1; -- debug builds only
    SET GLOBAL innodb_purge_stop_now = 1; -- debug builds only
    SET GLOBAL innodb_log_checkpoint_now = 1; -- debug builds only
    SET GLOBAL innodb_buf_flush_list_now = 1; -- debug builds only
    SET GLOBAL innodb_buffer_pool_dump_now = 1;
    SET GLOBAL innodb_buffer_pool_load_now = 1;
    SET GLOBAL innodb_buffer_pool_load_abort = 1;
    SET GLOBAL innodb_status_output = …;
    SET GLOBAL innodb_status_output_locks = …;
    SET GLOBAL innodb_encryption_threads = …;
    SET GLOBAL innodb_encryption_rotate_key_age = …;
    SET GLOBAL innodb_encryption_rotation_iops = …;
    SET GLOBAL innodb_encrypt_tables = …;
    SET GLOBAL innodb_disallow_writes = …;
    
    buf_LRU_old_ratio_update(): Correct the return type.
    626f2a1c
ha_innodb.cc 649 KB