• Vlad Lesin's avatar
    MDEV-29515 innodb.deadlock_victim_race is unstable · 5ab78cf3
    Vlad Lesin authored
    The test is unstable because 'UPDATE t SET b = 100' latches a page and
    waits for 'upd_cont' signal in lock_trx_handle_wait_enter sync point, then
    purge requests RW_X_LATCH on the same page, and then 'SELECT * FROM t
    WHERE a = 10 FOR UPDATE' requests RW_S_LATCH, waiting for RW_X_LATCH
    requested by purge. 'UPDATE t SET b = 100' can't release page latch as
    it waits for upd_cont signal, which must be emitted after 'SELECT * FROM
    t WHERE a = 10 FOR UPDATE' acquired RW_S_LATCH. So we have a deadlock,
    which is resolved by finishing the debug sync point wait by timeout, and
    the 'UPDATE t SET b = 100' releases it's record locks rolling back the
    transaction, and 'SELECT * FROM t WHERE a = 10 FOR UPDATE' is finished
    successfully instead of finishing by lock wait timeout.
    
    The fix is to forbid purging during the test by opening read view in a
    separate connection before the first insert into the table.
    
    Besides, 'lock_wait_end' syncpoint is not needed, as it enough to wait
    the end of the SELECT execution to let the UPDATE to continue.
    5ab78cf3
deadlock_victim_race.test 4.36 KB