Bug #29851 TRUNCATE causes error 4350 from cluster in INSERT... ON DUPLICATE KEY UPDATE
Submitted: 17 Jul 2007 18:05 Modified: 20 Feb 2008 20:58
Reporter: Todd Farmer (OCA) 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: Guangbao Ni CPU Architecture:Any

[17 Jul 2007 18:05] Todd Farmer
Description:
When TRUNCATE and INSERT ... ON DUPLICATE KEY UPDATE statements are both executed against the same NDB table using the same mysqld instance, the INSERT ... ON DUPLICATE KEY UPDATE statement generates the following error:

ERROR 1296 (HY000): Got error 4350 'Transaction already aborted' from ndbcluster

Subsequent executions of the same INSERT ... ON DUPLICATE KEY UPDATE statement (after the TRUNCATE operation has completed) result in the same error, even though straight INSERT statements complete without errors:

mysql> insert into truncate_test values (2, 2, 'blah') on duplicate key update b='again';
ERROR 1296 (HY000): Got error 4350 'Transaction already aborted' from ndbcluster
mysql> insert into truncate_test values (2, 2, 'blah') on duplicate key update b='again';
ERROR 1296 (HY000): Got error 4350 'Transaction already aborted' from ndbcluster
mysql> select * from truncate_test;
Empty set (0.01 sec)

mysql> insert into truncate_test values (2, 2, 'blah') on duplicate key update b='again';
ERROR 1296 (HY000): Got error 4350 'Transaction already aborted' from ndbcluster
mysql> insert into truncate_test values (2, 2, 'blah');
Query OK, 1 row affected (0.01 sec)

mysql> insert into truncate_test values (2, 2, 'blah') on duplicate key update b='again';
ERROR 1296 (HY000): Got error 4350 'Transaction already aborted' from ndbcluster
mysql> select * from truncate_test;
+---+------+------+
| i | a    | b    |
+---+------+------+
| 2 |    2 | blah |
+---+------+------+
1 row in set (0.01 sec)

How to repeat:
CREATE TABLE truncate_test (
  i INT PRIMARY KEY,
  a INT,
  b VARCHAR(11),
  UNIQUE KEY (a) 
) ENGINE = NDB;

INSERT INTO truncate_test VALUES (1, 1, 'test') ON DUPLICATE KEY UPDATE b = 'new';
INSERT INTO truncate_test VALUES (1, 1, 'test') ON DUPLICATE KEY UPDATE b = 'new';
 -- issue TRUNCATE truncate_test in second client, while issuing the next statement in initial client:
INSERT INTO truncate_test VALUES (1, 1, 'test') ON DUPLICATE KEY UPDATE b = 'new';
-- once truncate operation completes, execute:
INSERT INTO truncate_test VALUES (1, 1, 'test') ON DUPLICATE KEY UPDATE b = 'new';
SELECT * FROM truncate_test;
INSERT INTO truncate_test VALUES (1, 1, 'test');
SELECT * FROM truncate_test;
INSERT INTO truncate_test VALUES (1, 1, 'test') ON DUPLICATE KEY UPDATE b = 'new';

Suggested fix:
Resolve so that no error is generated.
[20 Jul 2007 21:20] Bob Pisani
I get this error repeatedly on version 5.1.20 on a new cluster setup I'm testing. I'm using Open SUSE 10.2:

Got error 4350 'Transaction already aborted' from NDB

The circumstances under which I get it are different though. Using the jdbc driver I submit batches of 100 insert statements (or just execute 100 and then commit) to a disk based ndb table. After 3 or so batches, I get this error. No other errors are in the log. I even see the error when trying to delete the data using Query browser.

Any ideas? I've now seen this issue raised in several other bugs.
[31 Aug 2007 8:13] 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/33515

ChangeSet@1.2476, 2007-08-31 16:03:53+08:00, gni@dev3-221.dev.cn.tlan +1 -0
  BUG#29851 TRUNCATE causes error 4350 from cluster in INSERT... ON DUPLICATE KEY UPDATE
[12 Sep 2007 12:25] Guangbao Ni
merged into mysql-5.1.22-ndb-6.2.5
[12 Sep 2007 12:41] Guangbao Ni
Sorry, wrong comments, not merge yet.
[28 Sep 2007 1:26] 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/34622

ChangeSet@1.2476, 2007-09-28 09:16:41+08:00, gni@dev3-221.dev.cn.tlan +3 -0
  BUG#29851 TRUNCATE causes error 4350 from cluster in INSERT... ON DUPLICATE KEY UPDATE
[9 Jan 2008 3:21] Guangbao Ni
pushed into mysql-5.0-ndb-bj
[1 Feb 2008 21:47] Jon Stephens
Documented in 5.1.23-ndb-6.3.8 changelog as follows:

      
        Issuing an INSERT ... ON DUPLICATE KEY UPDATE
        concurrently with or following a TRUNCATE
        statement on an NDB table failed with
        NDB error 4350 Transaction already
        aborted.
      
Left in PQ status pending further merges.
[2 Feb 2008 11:10] Jon Stephens
Also documented for 5.1.23-ndb-6.2.11; left bug status unchanged.
[20 Feb 2008 16:02] Bugs System
Pushed into 5.0.58
[20 Feb 2008 16:02] Bugs System
Pushed into 5.1.24-rc
[20 Feb 2008 16:03] Bugs System
Pushed into 6.0.5-alpha
[20 Feb 2008 20:58] Jon Stephens
Also documented for 5.0.58, 5.1.24, and 6.0.5.