• Sergei Petrunia's avatar
    MDEV-33533: Crash at execution of DELETE when trying to use rowid filter · fe41171c
    Sergei Petrunia authored
    (Based on original patch by Oleksandr Byelkin)
    
    Multi-table DELETE can execute via "buffered" mode: at phase #1 it collects
    rowids of rows to be deleted, then at phase #2 in multi_delete::do_deletes()
    it calls handler->rnd_pos() to read rows to be deleted and deletes them.
    
    The problem occurred when phase #1 used Rowid Filter on the table that
    phase #2 would be deleting from.
    In InnoDB, h->rnd_init(scan=false) and h->rnd_pos() is an index scan over PK
    under the hood. So, at phase #2 ha_innobase::rnd_init() would try to use the
    Rowid Filter and hit an assertion inside ha_innobase::rnd_init().
    
    Note that multi-table UPDATE works similarly but was not affected, because
    patch for MDEV-7487 added code to disable rowid filter for phase #2 in
    multi_update::do_updates().
    
    This patch changes the approach:
    - It makes InnoDB not use Rowid Filter in rnd_pos() scans: it is disabled in
      ha_innobase::rnd_init() and enabled back in ha_innobase::rnd_end().
    - multi_update::do_updates() no longer disables Rowid Filter for phase#2 as
      it is no longer necessary.
    fe41171c
update_innodb.test 5.63 KB