Bug #16924 ndbapi tuple insertion does not work
Submitted: 31 Jan 2006 8:27 Modified: 14 Feb 2006 9:11
Reporter: patrice audigou Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Cluster: Cluster (NDB) storage engine Severity:S1 (Critical)
Version:5.1.6-alpha OS:Linux (redHat9)
Assigned to: Jonas Oreland CPU Architecture:Any

[31 Jan 2006 8:27] patrice audigou
Description:
On a simple cluster (only one db node,without replication) a tuple
insertion using ndbapi crashes with the following error message :
 
        code: 4010, msg: Node failure caused abort of transaction 

(it works using Mysql client )

How to repeat:
 create following  table with ndbapi :
========================

if (mysql_query(&mysql,
                "CREATE TABLE"
                " IMSI "
                " ( "
                "MSIN CHAR(11)  NOT NULL,"
                "MNC CHAR(4) NOT NULL,"
                "MCC CHAR(4) NOT NULL,"
                "mainMSISDN VARBINARY(21),"
                "alertMSISDN VARBINARY(21),"
                "associatedMSISDN VARBINARY(151),"
                "bitAttr  BIT(1),"
                "bit33Attr  BIT(33),"
                "charAttr  CHAR(1),"
                "shortAttr  SMALLINT,"
                "int32Attr  INT UNSIGNED,"
                "int64Attr  BIGINT UNSIGNED,"
                "stringAttr  CHAR(16),"
                "bcdAttr  BINARY(10),"
                "binAttr  BINARY(16),"
                "bcdset     BINARY(35),"
                "bcdarr     BINARY(35),"
                "binset     BINARY(21),"
                "binarr     BINARY(31),"
                "crossJoinIdx     VARBINARY(7),"
                "suMSubscriptionProfileId INT,"
                "suMSubscriberProfileId CHAR(12),"
                " PRIMARY KEY USING HASH (MSIN,MNC,MCC) ) engine=ndb PARTITION BY KEY (MSIN)"))
    MYSQLERROR(mysql);

Try to insert a tuple :
=============

    myOperation->insertTuple();
    myOperation->equal("MSIN", "888889");
    myOperation->equal("MNC", "1");
    myOperation->equal("MCC", "1");
                                                                                                                               
    if (myTransaction->execute( NdbTransaction::Commit ) == -1)
      APIERROR(myTransaction->getNdbError());
[31 Jan 2006 8:33] Jonas Oreland
Hi,

unless you want to get into the charset business.
I suggest changing char(4) to binary(4), otherwise you need to insert string wrt charset/collation. which is tricky...

It's probly why it fails...
[31 Jan 2006 11:59] Jonas Oreland
ok. then the charsets is not the problem.
Have you left out "setValues" of other attributes or does your code look exactly like what you pasted.

The handling of var{char/binary} has changed between 5.1.something and 5.1.6.
Namely now it supports true variable size.
But this has implications on how you should format your data...
[31 Jan 2006 18:12] Jonas Oreland
Hi,

No I have not tested it. It's probably a bug, it should return another error code.

>Concerning the new feature , variable size ayttribute , i suppose that there is
>no impact on existing software except the declaration of variable size columns.

This is incorrect.
You need to format your values according to mysql format of variable size attributes.
This is 99% sure why you have trouble.

var{char/binary} [X] where X < 256  _must_ contain length of attribute in first byte
                             where x >= 256 _must_ contain lenght of attribute in first two bytes(little endin)

example:
create table t1 (a varchar(100), b varchar(500));
insert into t1 values ('x', 'y');

setValue('a', { 1, x })
setValue('b', { 1, 0, y }

so this has changed!
and as I said this is likely the cause of your problem.

But it's still a bug that you get 4010.

Can you test if this will solve your problem and we keep the bug report open so I can fix 
  error code.

/Jonas
[31 Jan 2006 19:06] Jonathan Miller
Decided to mark it back down since Jonas thinks it might just be error code issue  at this point. We can always set Priority back if AQA is not sucessful with what Jonas has provided.
[2 Feb 2006 13:02] Tomas Ulin
can you clarify:

Do you get a problem if you set attributes to null?

Or do you get a problem when you leave out setting an attribute value?

E.g. from the mysql server this works fine;

create table t2 (a varchar(100) CHARACTER SET latin1 COLLATE latin1_bin, b varchar(500) CHARACTER SET latin1 COLLATE latin1_bin) engine=ndb;
insert into t2 values (NULL, NULL);
insert into t2 values ('X', NULL);

So null handling seems to work when NULL is explicitly set

master> select * from t2;
+------+------+
| a    | b    |
+------+------+
| NULL | NULL |
| X    | NULL |
+------+------+

BR,

Tomas
[2 Feb 2006 16:49] Jonathan Miller
The developers would like some more detail. Could you provide a code example of the current API code that has issues with output recieved? And maybe the change for previous?

Thanks.
[3 Feb 2006 8:35] patrice audigou
simple example which works

Attachment: ndbapi_error_ok.cpp (text/x-c++), 9.18 KiB.

[3 Feb 2006 8:41] patrice audigou
I have attached three files to this bug report.

1) ndbapi_error_ok.cpp : example which works
2) ndbapi_error_ko.cpp : example which fails
3) createtableNew.sql   : table creation

the hlr database need to be create which the following options :

create database hlr default charset=latin1 default collate=latin1_bin;
[7 Feb 2006 10:27] Jonas Oreland
Fix

Attachment: bug16924.patch (text/x-patch), 759 bytes.

[7 Feb 2006 10:28] 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/2228
[7 Feb 2006 10:29] Jonas Oreland
Hi,

I attached a bug fix.
Otherwise this will be in 5.1.7
[7 Feb 2006 10:45] Jonas Oreland
pushed into 5.1.7