Forum: Building VoltDB Applications

Post: Mispartitioned tuple in single-partition insert statement.

Mispartitioned tuple in single-partition insert statement.
dashirov
Mar 23, 2016
If you're seeing an error that reads similar to the following during execution of a partitioned stored procedure (from class) and you're pretty sure you're not insane...

ERROR: Invalid input on line xxx. VOLTDB ERROR: CONSTRAINT VIOLATION
Mispartitioned tuple in single-partition insert statement.
Constraint Type PARTITIONING, Table CatalogId TBL

Check if the procedure partition key happens to be at the first position in the run() function's parameter list. If it is not, than make sure you've created the procedure with
optional POSITION clause set to 0-indexed position of the partition key in the parameter list. You may save yourself a few days of debugging and hair pulling.
bballard
Mar 23, 2016
Thanks for sharing this tip. One small correction, if the partitioning key value is not the first parameter to the procedure's run() method, then you need to specify [PARAMETER position] when you define the procedure partitioning, which can be done either with a PARTITION PROCEDURE statement, or within the CREATE PROCEDURE statement.

CREATE PROCEDURE FROM CLASS: https://docs.voltdb.com/UsingVoltDB/ddlref_createprocjava.php
CREATE PROCEDURE AS: https://docs.voltdb.com/UsingVoltDB/ddlref_createprocsql.php
PARTITION PROCEDURE: https://docs.voltdb.com/UsingVoltDB/ddlref_partitionproc.php

Also, remember that the "position" number is counted starting from 0, i.e. 0,1,2,...