Transaction already aborted.
I tried to execute the sample program here:
https://dev.mysql.com/doc/ndbapi/en/ndb-examples-synchronous-transactions.html
I modified the table to store varchar data.
Table:
mysql> show create table KV_STORE;
+----------+----------------------------------------------------------------------------------------------------------------------------------------------
----------------+
| Table | Create Table
|
+----------+----------------------------------------------------------------------------------------------------------------------------------------------
----------------+
| KV_STORE | CREATE TABLE `KV_STORE` (
`ATTR1` varchar(25) NOT NULL,
`ATTR2` varchar(50) NOT NULL,
PRIMARY KEY (`ATTR1`)
) ENGINE=ndbcluster DEFAULT CHARSET=latin1 |
+----------+----------------------------------------------------------------------------------------------------------------------------------------------
----------------+
I modified the do_insert to insert a string type data.
static void do_insert(Ndb &myNdb)
{
const NdbDictionary::Dictionary* myDict= myNdb.getDictionary();
const NdbDictionary::Table *myTable= myDict->getTable("KV_STORE");
if (myTable == NULL)
APIERROR(myDict->getNdbError());
NdbTransaction *myTransaction= myNdb.startTransaction();
if (myTransaction == NULL) APIERROR(myNdb.getNdbError());
NdbOperation *myOperation= myTransaction->getNdbOperation(myTable);
if (myOperation == NULL) APIERROR(myTransaction->getNdbError());
myOperation->insertTuple();
myOperation->equal("ATTR1", std::to_string(1).c_str());
myOperation->setValue("ATTR2", std::to_string(1).c_str());
if (myTransaction->execute( NdbTransaction::Commit ) == -1)
APIERROR(myTransaction->getNdbError());
myNdb.closeTransaction(myTransaction);
}
I am getting the following error:
NDB Cluster already has example table: KV_STORE. Dropping it...
Error in src/NdbThroughput.cc, line: 188, code: 4350, msg: Transaction already aborted.