Bug #31874 Failure for NDB update/delete with combined range and equality constraints
Submitted: 26 Oct 2007 11:02 Modified: 6 Nov 2007 8:32
Reporter: Kristian Nielsen Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Cluster: Cluster (NDB) storage engine Severity:S2 (Serious)
Version:mysql-6.0, mysql-telco-6.2 OS:Any
Assigned to: Kristian Nielsen CPU Architecture:Any

[26 Oct 2007 11:02] Kristian Nielsen
Description:
create table t1 (
  a int not null primary key,
  b int
) engine = ndb;
insert into t1 values (7,2),(8,3),(10,4);
update t1 set b = 5 where a in (7,8) or a >= 10;

 -> "got unknown error from ndb"

The problem is a bug in the read_multi_range_next() call. This call is used to scan a table using a combination of primary key equality lookups and range scans. In the above example there are two primary key looks (a=7 or a=8) and one range scan (a >= 10).

In some cases, read_multi_range_next() fails to correctly set a flag to determine whether the current row comes from a primary key lookup or from a scan. When this happens, updates or deletes execute wrongly.

How to repeat:
Will comit test case.

Suggested fix:
Will commit patch.
[26 Oct 2007 11:09] 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/36426

ChangeSet@1.2676, 2007-10-26 13:09:35+02:00, knielsen@ymer.(none) +4 -0
  Bug #31874: Failure for NDB update/delete with combined range and equality constraints
  
  In update/delete with read_multi_range, when mixing pk lookups and range
  scans, sometimes update/delete did not correctly distinguish whether
  the current row was from pk lookup or from scan. This caused query
  failure (or potentially memory corruption and crash).
  
  Fix by setting proper flags in the read_multi_range_next() method.
[26 Oct 2007 11:41] Kristian Nielsen
Pushed to mysql-5.1-telco-6.2 and mysql-5.1-telco-6.3
[5 Nov 2007 13:53] Bugs System
Pushed into 6.0.4-alpha
[5 Nov 2007 21:30] Jon Stephens
Documented in mysql-5.1.22-ndb-6.2.8, mysql-5.1.22-ndb-6.3.6, and 6.0.4 changelogs.

Please advise as to whether this fix will appear in 5.1-main and if so, the applicable version.
[6 Nov 2007 7:48] Kristian Nielsen
This will not appear in 5.1-main, as the bug is not in 5.1, it was introduced only in 6.0.
[6 Nov 2007 8:32] Jon Stephens
Closed, no further documentation required. Thanks for the info.