{"record":{"id":"519ee88865e85324","repo":"apache/cassandra","slug":"may-only-delete-on-txn-id-and-id-micros","errorCode":null,"errorMessage":"May only delete on txn_id and id_micros","messagePattern":"May only delete on txn_id and id_micros","errorType":"exception","errorClass":"InvalidRequestException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/db/virtual/AccordDebugKeyspace.java","lineNumber":1240,"sourceCode":"                        \"  command_store_id int,\\n\" +\n                        \"  remote_node_id int,\\n\" +\n                        \"  message text,\\n\" +\n                        \"  PRIMARY KEY (txn_id, id_micros, event, at_micros)\" +\n                        ')', TxnIdUtf8Type.instance), FAIL, UNSORTED, UNSORTED);\n        }\n\n        @Override\n        protected void applyPartitionDeletion(Object[] partitionKeys)\n        {\n            TxnId txnId = TxnId.parse((String)partitionKeys[0]);\n            tracing().eraseEvents(txnId);\n        }\n\n        @Override\n        protected void applyRangeTombstone(Object[] partitionKeys, Object[] starts, boolean startInclusive, Object[] ends, boolean endInclusive)\n        {\n            TxnId txnId = TxnId.parse((String) partitionKeys[0]);\n            if (starts.length > 1 || ends.length > 1) throw invalidRequest(\"May only delete on txn_id and id_micros\");\n\n            long minId = Long.MIN_VALUE, maxId = Long.MAX_VALUE;\n            if (starts.length == 1)\n            {\n                minId = ((Long)starts[0]);\n                if (!startInclusive && minId < Long.MAX_VALUE)\n                    ++minId;\n            }\n            if (ends.length == 1)\n            {\n                maxId = ((Long)ends[0]);\n                if (!endInclusive && maxId > Long.MIN_VALUE)\n                    --maxId;\n            }\n            tracing().eraseEventsBetween(txnId, minId, maxId);\n        }\n\n        @Override","sourceCodeStart":1222,"sourceCodeEnd":1258,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/db/virtual/AccordDebugKeyspace.java#L1222-L1258","documentation":"In the AccordDebugKeyspace txn_id-keyed virtual table, range tombstones over the clustering columns are only meaningful when the range is expressed on the single clustering column id_micros. applyRangeTombstone throws this error when the DELETE's clustering range involves more than one clustering column bound (starts.length > 1 or ends.length > 1), since the table cannot map multi-column ranges onto a single id_micros interval.","triggerScenarios":"Executing a ranged DELETE like `DELETE FROM table WHERE txn_id = '...' AND id_micros > 1 AND other_col < 5` (or any multi-clustering-column range) against this debug virtual table.","commonSituations":"Administrators cleaning up Accord txn records with generic range-delete queries modeled after normal tables with composite clustering keys; debugging scripts assuming full CQL range semantics on virtual tables.","solutions":["Restrict the DELETE range to only the id_micros clustering column: `DELETE FROM ... WHERE txn_id = '...' AND id_micros >= x AND id_micros <= y`.","Delete individual rows one at a time instead of a multi-column range.","Delete the entire partition (`DELETE FROM ... WHERE txn_id = '...';`) if the table supports it.","If broader cleanup is needed, use the underlying Accord state tooling rather than this debug table."],"exampleFix":"// before\nDELETE FROM system.accord_debug WHERE txn_id = '...' AND id_micros > 5 AND some_col < 10; // multi-column range\n// after\nDELETE FROM system.accord_debug WHERE txn_id = '...' AND id_micros > 5; // single-column range only","handlingStrategy":"validation","validationCode":"// Ensure the DELETE range touches only the id_micros clustering column\nif (whereClauseColumns.stream().filter(c -> !c.equals(\"txn_id\") && !c.equals(\"id_micros\")).count() > 0)\n    throw new IllegalArgumentException(\"Only txn_id and id_micros predicates allowed\");","typeGuard":null,"tryCatchPattern":"try { session.execute(deleteStmt); }\ncatch (InvalidRequestException e) { if (e.getMessage().equals(\"May only delete on txn_id and id_micros\")) { /* rewrite range on id_micros only */ } else throw e; }","preventionTips":["Remember this debug table has a single effective clustering column for ranges.","Express cleanup ranges purely on id_micros bounds.","Use per-row deletes or full-partition deletes for anything more complex."],"tags":["virtual-table","range-tombstone","invalid-request","accord"],"backgroundTag":"invalid-argument-value","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}