• Daniele Sciascia's avatar
    Fix FK constraint violation in applier, after ALTER TABLE ADD FK · 4d2b5523
    Daniele Sciascia authored
    Adding a FK constraint to an existing table (ALTER TABLE ADD FOREIGN
    KEY) causes the applier to fail, if a concurrent DML statement that
    violate the new constraint (i.e. a DELETE or UPDATE of record in the
    parent table).
    
    For exmaple, the following scenario causes a crash in the applier:
    
    1. ALTER successfully adds FK constraint in node_1
    2. On node_2 is UPDATE is in pre_commit() and has certified successfully
    3. ALTER is delivered in node_2 and BF aborts DML
    4. Applying UPDATE event causes FK violation in node_1
    
    To avoid this situation it is necessary for UPDATE to fail during
    certification. And for the UPDATE to fail certfication it is necessary
    that ALTER appends certification keys for both the child and the parent
    table. Before this patch, ALTER TABLE ADD FK only appended keys for
    child table which is ALTERed.
    4d2b5523
mysql-wsrep#332.result 3.57 KB