apache/cassandra · error · InvalidRequestException
table of additional mutation does not match primary update…
Error message
table of additional mutation does not match primary update table
What it means
Along with the partition key, validateSamePartition checks that any PartitionUpdate produced by a trigger targets the same table (TableId) as the primary update. A mismatched table id means the trigger would write to a different table within a single-partition atomic modification, which is not permitted, so this InvalidRequestException is thrown.
Solutions
- Make the trigger write to the same table as the statement, or remove the trigger from tables where it cannot comply
- Drop and recreate the trigger so it is only attached to the table it actually writes to
- Move the write to the other table into application code
Example fix
// before (trigger code) PartitionUpdate up = PartitionUpdate.builder(auditTable, key).build(); // after PartitionUpdate up = PartitionUpdate.builder(primaryTable, key).build();
Defensive patterns
Strategy: validation
Validate before calling
// inside trigger: assert table id matches assert update.metadata().id.equals(tableId) : 'trigger update table mismatch';
Try / catch
catch InvalidRequestException mentioning 'table of additional mutation does not match' and route the write elsewhere
Prevention
- Only attach a trigger to the exact table it writes to
- Query system_schema.triggers regularly to audit trigger/table pairing
- Avoid hardcoded table names in trigger implementations
When it happens
Trigger: A trigger returns a PartitionUpdate whose metadata().id (table) differs from the TableId of the table being modified by the original statement.
Common situations: Triggers writing to a secondary/audit table defined alongside the primary table; trigger configured with a hardcoded table name that doesn't match the statement's table; trigger reused across multiple tables.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- Partition key of additional mutation does not match primary…
- The updates generated by triggers are not all for the same…
- Can only unset '" + name + "'
- Counter mutations and trigger mutations cannot be applied…
- Invalid tuple literal for
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/f1b47677c9ac9c0c.
Report an issue: GitHub.
Appendix: source
Thrown at src/java/org/apache/cassandra/triggers/TriggerExecutor.java:219
for (Mutation mutation : tmutations)
{
for (PartitionUpdate update : mutation.getPartitionUpdates())
{
validateSamePartition(tableId, key, update);
updates.add(update);
}
}
return updates;
}
private void validateSamePartition(TableId tableId, DecoratedKey key, PartitionUpdate update)
throws InvalidRequestException
{
if (!key.equals(update.partitionKey()))
throw new InvalidRequestException("Partition key of additional mutation does not match primary update key");
if (!tableId.equals(update.metadata().id))
throw new InvalidRequestException("table of additional mutation does not match primary update table");
}
private void validate(Collection<Mutation> tmutations) throws InvalidRequestException
{
for (Mutation mutation : tmutations)
{
QueryProcessor.validateKey(mutation.key().getKey());
for (PartitionUpdate update : mutation.getPartitionUpdates())
update.validate();
}
}
/**
* Switch class loader before using the triggers for the column family, if
* not loaded them with the custom class loader.
*/
private List<Mutation> executeInternal(PartitionUpdate update)
{View on GitHub (pinned to 88fd0f6a0e)