Bug #30337 DELETE ... WHERE PK IN (..) and AFTER DELETE trigger crashes API node
Submitted: 9 Aug 2007 16:35 Modified: 13 Sep 2007 15:07
Reporter: Axel Schwenke Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Cluster: Cluster (NDB) storage engine Severity:S2 (Serious)
Version:5.0.44 OS:Linux
Assigned to: Martin Skold CPU Architecture:Any

[9 Aug 2007 16:35] Axel Schwenke
Description:
With an AFTER DELETE trigger on a NDB table, DELETE FROM table WHERE pk_column IN (list) makes mysqld crash. Deleting single rows works. Deleting with just one element in the (list) works as well. Without the trigger there is no crash.

Backtrace:

...
#5  <signal handler called>
#6  0x401f6871 in kill () from /lib/libc.so.6
#7  0x40057501 in pthread_kill (thread=Variable "thread" is not available.
) at signals.c:65
#8  0x4005754b in __pthread_raise (sig=1074127620) at signals.c:196
#9  0x401f6604 in *__GI_raise (sig=Variable "sig" is not available.
)
    at ../linuxthreads/sysdeps/unix/sysv/linux/raise.c:34
#10 0x401f7aac in *__GI_abort () at ../sysdeps/generic/abort.c:88
#11 0x401ef99a in *__GI___assert_fail (assertion=0x0, file=0x0, line=0, 
    function=Variable "function" is not available.
) at assert.c:83
#12 0x082e3f0a in ha_ndbcluster::setup_recattr (this=0x8bf0348, curr=0x0)
    at ha_ndbcluster.cc:6790
#13 0x082e3de3 in ha_ndbcluster::read_multi_range_next (this=0x8bf0348, 
    multi_range_found_p=0xbdbfeb10) at ha_ndbcluster.cc:6766
#14 0x082aabd2 in QUICK_RANGE_SELECT::get_next (this=0x8c08e30)
    at opt_range.cc:6819
#15 0x082b46f5 in rr_quick (info=0xbdbfed74) at records.cc:224
#16 0x0826e60b in mysql_delete (thd=0x8bb8770, table_list=0x8bf10f8, 
    conds=0x8bf1488, order=0x8bb97f8, limit=4294967294, options=0, 
    reset_auto_increment=false) at sql_delete.cc:234
...

How to repeat:
drop table if exists t1;
create table t1 (id int primary key) engine ndb;
insert into t1 values (1), (2), (3);

drop table if exists t2;
create table t2 (id int primary key) engine ndb;
insert into t2 select id from t1;

delimiter //
create trigger kaboom after delete on t1
for each row begin
  delete from t2 where id=old.id;
end //
delimiter ;

delete from t1 where id in (1,2);
[13 Aug 2007 9:36] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/32435

ChangeSet@1.2473, 2007-08-13 11:36:30+02:00, mskold@mysql.com +1 -0
  bug#30337  DELETE ... WHERE PK IN (..) and AFTER DELETE trigger crashes API node: Disable multi_read_range if there are after delete/update triggers
[13 Aug 2007 13:59] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/32449

ChangeSet@1.2474, 2007-08-13 15:59:08+02:00, mskold@mysql.com +2 -0
  bug#30337  DELETE ... WHERE PK IN (..) and AFTER DELETE trigger crashes API node: Added testcase
[13 Aug 2007 23:45] Stewart Smith
from my (limited) knowledge of the read multi range code, seems to make sense.
[14 Aug 2007 8:29] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/32493

ChangeSet@1.2577, 2007-08-14 10:29:00+02:00, mskold@mysql.com +1 -0
  bug#30337  DELETE ... WHERE PK IN (..) and AFTER DELETE trigger crashes API node: Regenerated result
[7 Sep 2007 18:54] Jon Stephens
Documented in mysql-5.1.22-ndb-6.2.5 changelog as:

            <literal>DELETE FROM <replaceable>table</replaceable> WHERE
              <replaceable>primary_key</replaceable> IN
              (<replaceable>value_list</replaceable>)</literal>, where
            the <replaceable>value_list</replaceable> contained more
            than one value, called from an <literal>AFTER
            DELETE</literal> trigger on an <literal>NDB</literal>
            table, caused <command>mysqld</command> to crash. (Bug
            #30337)

Left PQ status pending pushes to mainline trees.
[13 Sep 2007 13:37] Martin Skold
Pushed to 5.1.21
[13 Sep 2007 15:07] Jon Stephens
Thank you for your bug report. This issue has already been fixed in the latest released version of that product, which you can download at

  http://www.mysql.com/downloads/

Documented fix in 5.1.21 changelog.
[13 Sep 2007 15:09] Jon Stephens
Removed bugfix report from mysql-5.1.22-ndb-6.2.5 changelog since this had already been fixed prior to 5.1.22 -> cge-6.2.x merge.
[14 Sep 2007 16:25] Bugs System
Pushed into 5.0.50
[14 Sep 2007 16:25] Bugs System
Pushed into 5.1.23-beta