Bug #31239 Test "ndb_views" returns NDB error 4259 "Invalid set of range scan bounds"
Submitted: 27 Sep 2007 13:29 Modified: 25 Feb 2008 17:17
Reporter: Joerg Bruehe Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Cluster: Cluster (NDB) storage engine Severity:S2 (Serious)
Version:5.1.22-rc, 5.0.50 OS:Other (ICC / IA64)
Assigned to: Magnus Blåudd CPU Architecture:Any
Tags: icc

[27 Sep 2007 13:29] Joerg Bruehe
Description:
Found in the release builds of 5.1.22-rc.

Bug is specific to builds done using ICC for the IA64 CPU.

-------------------------------------------------------
*** /PATH/mysql-test/suite/funcs_1/r/ndb_views.result
--- /PATH/mysql-test/suite/funcs_1/r/ndb_views.reject
***************
*** 1922,1930
  4     four
  5     five
  SELECT * FROM v1 ORDER BY f1;
! f1    f2
! 2     two
! 4     four
  INSERT INTO v1 VALUES(2,'two');
  ERROR 23000: Duplicate entry '2' for key 'PRIMARY'
  INSERT INTO v1 VALUES(3,'three');
--- 1922,1928
  4     four
  5     five
  SELECT * FROM v1 ORDER BY f1;
! ERROR HY000: Got error 4259 'Invalid set of range scan bounds' from NDBCLUSTER
  INSERT INTO v1 VALUES(2,'two');
  ERROR 23000: Duplicate entry '2' for key 'PRIMARY'
  INSERT INTO v1 VALUES(3,'three');
***************
*** 1940,1949
  5     five
  6     six
  SELECT * FROM v1 ORDER BY f1;
! f1    f2
! 2     two
! 3     three
! 4     four
  UPDATE v1 SET f1 = 2 WHERE f1 = 3;
  ERROR 23000: Duplicate entry '2' for key 'PRIMARY'
  UPDATE v1 SET f2 = 'number' WHERE f1 = 3;
--- 1938,1944
  5     five
  6     six
  SELECT * FROM v1 ORDER BY f1;
! ERROR HY000: Got error 4259 'Invalid set of range scan bounds' from NDBCLUSTER
  UPDATE v1 SET f1 = 2 WHERE f1 = 3;
  ERROR 23000: Duplicate entry '2' for key 'PRIMARY'
  UPDATE v1 SET f2 = 'number' WHERE f1 = 3;
-------------------------------------------------------

How to repeat:
Found by running the test suite.
[26 Oct 2007 16:14] Magnus Blåudd
Minimal test file:
$> cat t/ndb_bug31239.test
source include/have_ndb.inc;

CREATE TABLE t1 (f1 BIGINT, f2 VARCHAR(20), PRIMARY KEY(f1))
  ENGINE = NDB;
INSERT INTO t1 VALUES(1,'one');
CREATE VIEW v1 AS SELECT * FROM t1 WHERE f1 BETWEEN 2 AND 4;

SELECT * FROM v1 ORDER BY f1;
[26 Oct 2007 17:25] Magnus Blåudd
From examining the trace files(comparing a failing and working) I can see that read_multi_range_first runs and it looks like it properly generates the scanfilter and send it to NDB, it then calls read_multi_range_next to fetch the rows and that's where it fails.
[30 Oct 2007 8:45] Magnus Blåudd
Further examination shows that it is the ndbd that returns the error code 4259.

msvensson@pilot:~/mysql/mysql-5.1-ndb/storage/ndb$ grep -r InvalidBound *
include/kernel/signaldata/TuxBound.hpp:    InvalidBounds = 4259,
src/kernel/blocks/dbtux/DbtuxScan.cpp:          sig->errorCode = TuxBoundInfo::InvalidBounds;
src/kernel/blocks/dbtux/DbtuxScan.cpp:        sig->errorCode = TuxBoundInfo::InvalidBounds;

By adding an abort() call just after the two lines in DbtuxScan.cpp it's possible to get a core from the ndbd.
[31 Jan 2008 21:09] Joerg Bruehe
Still present in 5.1.23-rc builds.
[1 Feb 2008 14:01] Magnus Blåudd
The problems occurs when a refernce to BoundInfo is set up. If printing the adress of "b", it will point to the next element in boundInfo. I.e as if maxAttrId[j] already has been incremented.

msvensson@pilot:~/mysql/mysql-5.0/ndb/src/kernel/blocks/dbtux$ bk diffs -u===== DbtuxScan.cpp 1.33 vs edited =====
--- 1.33/ndb/src/kernel/blocks/dbtux/DbtuxScan.cpp      2007-01-22 13:10:37 +01:00
+++ edited/DbtuxScan.cpp        2008-02-01 14:58:31 +01:00
@@ -216,7 +216,8 @@ Dbtux::execTUX_BOUND_INFO(Signal* signal
       // fill in any gap
       while (maxAttrId[j] <= attrId) {
         jam();
-        BoundInfo& b = boundInfo[j][maxAttrId[j]++];
+        BoundInfo& b = boundInfo[j][maxAttrId[j]];
+        maxAttrId[j]++;
         b.type2 = -1;
       }
       BoundInfo& b = boundInfo[j][attrId];
[1 Feb 2008 14:20] Magnus Blåudd
Minimal test case for 5.0

Attachment: ndb_basic.test (application/octet-stream, text), 1.38 KiB.

[5 Feb 2008 11:43] 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/41701

ChangeSet@1.2580, 2008-02-05 12:44:57+01:00, msvensson@pilot.mysql.com +1 -0
  Bug#31239 Test "ndb_views" returns NDB error 4259 "Invalid set of range scan bounds"
[25 Feb 2008 16:00] Bugs System
Pushed into 5.1.24-rc
[25 Feb 2008 16:05] Bugs System
Pushed into 5.0.58
[25 Feb 2008 16:06] Bugs System
Pushed into 6.0.5-alpha
[25 Feb 2008 17:17] Jon Stephens
Documented bugfix in the 5.0.58, 5.1.24, and 6.0.5 changelogs.
[30 Mar 2008 20:04] Jon Stephens
Fix also documented for 5.1.23-ndb-6.3.11.