apache/cassandra · error · InvalidRequestException
The updates generated by triggers are not all for the same…
Error message
The updates generated by triggers are not all for the same partition
What it means
When a trigger augments a single-partition mutation, all PartitionUpdates produced by the trigger must belong to the same partition. If a trigger returns a Mutation containing more than one PartitionUpdate, TriggerExecutor.validateForSinglePartition throws this InvalidRequestException because a single-partition write cannot be extended with updates to other partitions atomically.
Solutions
- Modify the trigger to return only a single PartitionUpdate per Mutation
- Have the trigger return multiple Mutation objects, each targeting one partition, instead of one Mutation with several updates
- Restrict the trigger to statements that are already multi-partition (e.g. batch), if the semantics allow
Example fix
// before (trigger code) return new Mutation(Arrays.asList(updateA, updateB)); // 2 partitions // after return Arrays.asList(new Mutation(updateA), new Mutation(updateB));
Defensive patterns
Strategy: try-catch
Validate before calling
// in trigger code, before returning
if (mutation.getPartitionUpdates().size() > 1) throw new IllegalArgumentException('Trigger must produce one partition update per Mutation'); Try / catch
catch InvalidRequestException mentioning 'not all for the same partition' and fall back to application-level writes
Prevention
- Keep each Mutation returned by a trigger limited to a single PartitionUpdate
- Unit-test triggers against single-partition statements
- Document trigger partition-key constraints in the trigger class
When it happens
Trigger: A trigger's execute() returns a Mutation whose getPartitionUpdates() yields more than one PartitionUpdate (e.g. the trigger writes to multiple rows/tables), and the originating statement is a single-partition modification.
Common situations: Triggers written against multi-partition semantics being attached to single-row statements; a trigger writing to more than one table in one Mutation; misunderstanding the trigger contract that each augmented Mutation must target one partition for single-partition requests.
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…
- table of additional mutation does not match primary update…
- 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/58637ad0b6f15541.
Report an issue: GitHub.
Appendix: source
Thrown at src/java/org/apache/cassandra/triggers/TriggerExecutor.java:195
List<Mutation> merged = new ArrayList<>(groupedMutations.size());
for (Pair<String, ByteBuffer> key : groupedMutations.keySet())
merged.add(Mutation.merge(groupedMutations.get(key)));
return merged;
}
private List<PartitionUpdate> validateForSinglePartition(TableId tableId,
DecoratedKey key,
Collection<Mutation> tmutations)
throws InvalidRequestException
{
validate(tmutations);
if (tmutations.size() == 1)
{
List<PartitionUpdate> updates = Lists.newArrayList(Iterables.getOnlyElement(tmutations).getPartitionUpdates());
if (updates.size() > 1)
throw new InvalidRequestException("The updates generated by triggers are not all for the same partition");
validateSamePartition(tableId, key, Iterables.getOnlyElement(updates));
return updates;
}
ArrayList<PartitionUpdate> updates = new ArrayList<>(tmutations.size());
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 InvalidRequestExceptionView on GitHub (pinned to 88fd0f6a0e)