DataStax Help Center

Compactions fail after schema change with "java.lang.AssertionError: Added column does not sort as the last column"


A schema update results in compaction failures with assertion errors.


Compaction threads fail with the following sample exception stack from DataStax Enterprise 4.6.5 (Cassandra 2.0.14):

ERROR [CompactionExecutor:6488] 2015-07-14 19:33:14,247 (line 258) Exception in thread Thread[CompactionExecutor:6488,1,main] 
java.lang.AssertionError: Added column does not sort as the last column 
at org.apache.cassandra.db.ArrayBackedSortedColumns.addColumn( 
at org.apache.cassandra.db.ColumnFamily.addColumn( 
at org.apache.cassandra.db.ColumnFamily.addAtom( 
at org.apache.cassandra.db.compaction.PrecompactedRow.merge( 
at org.apache.cassandra.db.compaction.PrecompactedRow.(


This issue is caused by changing the clustering order on a table where data already exists. In the example above, the original schema defined the clustering column in the default ascending order. At some point after data was inserted into the table, the table schema was altered such that the clustering column has been modified to be in descending order.

NOTE - The reverse also applies, i.e. clustering column sorted in descending order but later altered to ascending order.

Since there is already data in the table, the compaction fails since the row is sorted in the wrong order and cannot be added. For the same reason, existing data cannot be deserialised.


There is no real solution to this problem. Depending on the size of the data which needs to be corrected, it may be possible to extract the contents of the affected sstables (e.g. with `sstable2json`), then re-insert the data into Cassandra.

See also

DataStax doc - ALTER TABLE command

DataStax doc - sstable2json command

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request


Powered by Zendesk