• Marko Mäkelä's avatar
    MDEV-23651 InnoDB: Failing assertion: !space->referenced() · a7dd7c89
    Marko Mäkelä authored
    commit de942c9f (MDEV-15983)
    introduced a race condition that we inadequately fixed in
    commit 93b69825 (MDEV-16169).
    
    Because fil_space_t::release() or fil_space_t::acquire() are
    not protected by fil_system.mutex like their predecessors,
    it is possible that stop_new_ops was set between the time
    a thread checked fil_space_t::is_stopping() and invoked
    fil_space_t::acquire().
    
    In an execution trace, this happened in fil_system_t::keyrotate_next(),
    causing an assertion failure in fil_delete_tablespace()
    in the other thread that seeked to stop new operations.
    
    We fix this bug by merging the flag fil_space_t::stop_new_ops
    and the reference count fil_space_t::n_pending_ops into a
    single word that is only being accessed by atomic memory operations.
    
    fil_space_t::set_stopping(): Accessor for changing the state of
    the former stop_new_ops flag.
    
    fil_space_t::acquire(): Return whether the acquisition succeeded.
    It would fail between set_stopping(true) and set_stopping(false).
    a7dd7c89
fil0fil.cc 141 KB