• Denis Protivensky's avatar
    MDEV-34836: TOI on parent table must BF abort SR in progress on a child · 231900e5
    Denis Protivensky authored
    Applied SR transaction on the child table was not BF aborted by TOI running
    on the parent table for several reasons:
    
    Although SR correctly collected FK-referenced keys to parent, TOI in Galera
    disregards common certification index and simply sets itself to depend on
    the latest certified write set seqno.
    
    Since this write set was the fragment of SR transaction, TOI was allowed to
    run in parallel with SR presuming it would BF abort the latter.
    
    At the same time, DML transactions in the server don't grab MDL locks on
    FK-referenced tables, thus parent table wasn't protected by an MDL lock from
    SR and it couldn't provoke MDL lock conflict for TOI to BF abort SR transaction.
    
    In InnoDB, DDL transactions grab shared MDL locks on child tables, which is not
    enough to trigger MDL conflict in Galera.
    
    InnoDB-level Wsrep patch didn't contain correct conflict resolution logic due to
    the fact that it was believed MDL locking should always produce conflicts correctly.
    
    The fix brings conflict resolution rules similar to MDL-level checks to InnoDB,
    thus accounting for the problematic case.
    
    Apart from that, wsrep_thd_is_SR() is patched to return true only for executing
    SR transactions. It should be safe as any other SR state is either the same as
    for any single write set (thus making the two logically equivalent), or it reflects
    an SR transaction as being aborting or prepared, which is handled separately in
    BF-aborting logic, and for regular execution path it should not matter at all.
    Signed-off-by: default avatarJulius Goryavsky <julius.goryavsky@mariadb.com>
    231900e5
MDEV-34836.test 2.23 KB