Forum: Building VoltDB Applications

Post: Error in inserting partitioned table with composite primary key from multiple partitioned stored procedure

Error in inserting partitioned table with composite primary key from multiple partitioned stored procedure
pklalitjha
Sep 16, 2013
While following hello world in tutorial I made few changes in create table. Table has composite primary key with two columns (one is partition column). Rest of the tutorial has same code for procedures and DDL.

create table dictionary (
word varchar(50),
meaning varchar(50),
language varchar(50) not null,
primary key(word, language)
);
partition table dictionary on column language;

CREATE PROCEDURE FROM CLASS Insert;
CREATE PROCEDURE FROM CLASS Select;

PARTITION PROCEDURE Insert ON TABLE dictionary COLUMN language;
PARTITION PROCEDURE Select ON TABLE dictionary COLUMN language;

While inserting following data
client.callProcedure("Insert", "One", "1", "English");
client.callProcedure("Insert", "One", "1", "Roman");
I get fllowing error:

Exception in thread "main" org.voltdb.client.ProcCallException: VOLTDB ERROR: CONSTRAINT VIOLATION
Mispartitioned tuple in single-partition insert statement.
Constraint Type PARTITIONING, Table CatalogId DICTIONARY
header size: 37
status code: -128 column count: 3
cols (WORD:STRING), (MEANING:STRING), (LANGUAGE:STRING),
rows -
One,1,Roman

How to correct this partition? Is it like with this composite primary key which includes partition column will not work as multi partitioned table and need to be replicated table?
bballard
Sep 16, 2013
Hi,

The PARTITION PROCEDURE command has an optional PARAMETER option which defaults to 0. If "language" is not the first parameter to your stored procedure, then the default is incorrect. You probably need to set this more explicitly:

PARTITION PROCEDURE Insert ON TABLE dictionary COLUMN language PARAMETER 2; // assuming language is the 3rd parameter

There is more about this on the PARTITION PROCEDURE reference page:
http://voltdb.com/docs/UsingVoltDB/ddlref_partitionproc.php

Best regards,
Ben
pklalitjha
Sep 18, 2013
Hi Ben,

Thanks a lot.


Hi,

The PARTITION PROCEDURE command has an optional PARAMETER option which defaults to 0. If "language" is not the first parameter to your stored procedure, then the default is incorrect. You probably need to set this more explicitly:

PARTITION PROCEDURE Insert ON TABLE dictionary COLUMN language PARAMETER 2; // assuming language is the 3rd parameter

There is more about this on the PARTITION PROCEDURE reference page:
http://voltdb.com/docs/UsingVoltDB/ddlref_partitionproc.php

Best regards,
Ben