Bug #65130 "Transaction already aborted" hides real error msg on INSERT ... ON DUP UPDATE
Submitted: 27 Apr 2012 12:12 Modified: 23 May 2013 19:20
Reporter: Hartmut Holzgraefe Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Cluster: Cluster (NDB) storage engine Severity:S3 (Non-critical)
Version:7.1.x, 7.2.5 OS:Linux
Assigned to: CPU Architecture:Any

[27 Apr 2012 12:12] Hartmut Holzgraefe
Description:
When doing an INSERT ... ON DUPLICATE KEY UPDATE
on a cluster row where the row to be inserted
actually exists and is currently locked by another
transaction the error message returned from the 
INSERT after timeout is "Transaction already aborted"
instead of the expected "Lock wait timeout exceeded"

When just trying to INSERT without the ON DUPLICATE
part the already existing and locked row the result 
is a "Lock wait timeout exceeded" but it seems as
if the ON DUPLICATE UPDATE part is executed anyway
here (even though no duplicate key error was raised
for the pure INSERT), and this fails as the transaction
was already terminated by the lock wait timeout
encountered earlier, overwriting this previous error
code/message?

How to repeat:
in connection #1:

  create table t1(id int primary key, val int) engine=ndb;

  insert into t1 set id=1, val=23;

  begin;
  select * from t1 where id=1 for update;

now in connection #2

  begin; 
  insert into t1 set id=1, val=42 on duplicate key update val=42;

which results in the following error after the timeout has expired:

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

Suggested fix:
Do not overwrite the previous "Lock wait timeout" error
[11 May 2012 21:06] Sveta Smirnova
Thank you for the report.

Verified as described.
[12 Apr 2013 15:23] Nathan Deckinga
This is still valid for 7.2.10
[23 May 2013 19:20] Jon Stephens
Thank you for your bug report. This issue has been committed to our source repository of that product and will be incorporated into the next release.

If necessary, you can access the source repository and build the latest available version, including the bug fix. More information about accessing the source trees is available at

    http://dev.mysql.com/doc/en/installing-source.html
[23 May 2013 19:21] Jon Stephens
Documented fix in the NDB 6.3.53, 7.0.39, 7.1.28, and 7.2.14 changlogs:

        When performing an INSERT ... ON DUPLICATE KEY UPDATE on an NDB
        table where the row to be inserted already existed and was
        locked by another transaction, the error message returned from
        the INSERT following the timeout was "Transaction already
        aborted" instead of the expected "Lock wait timeout exceeded".

Closed.