{"record":{"id":"9e8a049be58904f2","repo":"apache/cassandra","slug":"cannot-drop-compact-storage-as-some-nodes-in-the-c-9e8a04","errorCode":null,"errorMessage":"Cannot DROP COMPACT STORAGE as some nodes in the cluster (%s) has some non-upgraded 2.x sstables. Please run `upgradesstables` on those nodes before retrying","messagePattern":"Cannot DROP COMPACT STORAGE as some nodes in the cluster \\((.+?)\\) has some non-upgraded 2\\.x sstables\\. Please run `upgradesstables` on those nodes before retrying","errorType":"validation","errorClass":"InvalidRequestException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/cql3/statements/schema/AlterTableStatement.java","lineNumber":819,"sourceCode":"                    {\n                        // Means VersionType::fromString didn't parse a version correctly. Which shouldn't happen, we shouldn't\n                        // have garbage in Gossip. But crashing the request is not ideal, so we log the error but ignore the\n                        // node otherwise.\n                        noSpamLogger.error(\"Unexpected error parsing sstable versions from gossip for {} (gossiped value \" +\n                                           \"is '{}'). This is a bug and should be reported. Cannot ensure that {} has no \" +\n                                           \"non-upgraded 2.x sstables anymore. If after this DROP COMPACT STORAGE some old \" +\n                                           \"sstables cannot be read anymore, please use `upgradesstables` with the \" +\n                                           \"`--force-compact-storage-on` option.\", node, sstableVersionsString, node);\n                    }\n                }\n            }\n\n            if (!before4.isEmpty())\n                throw new InvalidRequestException(format(\"Cannot DROP COMPACT STORAGE as some nodes in the cluster (%s) \" +\n                                                         \"are not on 4.0+ yet. Please upgrade those nodes and run \" +\n                                                         \"`upgradesstables` before retrying.\", before4));\n            if (!with2xSStables.isEmpty())\n                throw new InvalidRequestException(format(\"Cannot DROP COMPACT STORAGE as some nodes in the cluster (%s) \" +\n                                                         \"has some non-upgraded 2.x sstables. Please run `upgradesstables` \" +\n                                                         \"on those nodes before retrying\", with2xSStables));\n        }\n    }\n\n    public static class AlterConstraints extends AlterTableStatement\n    {\n        final ColumnIdentifier columnName;\n        final ColumnConstraints.Raw constraints;\n        final boolean ifColumnExists;\n\n        AlterConstraints(String keyspaceName, String tableName, boolean ifTableExists, boolean ifColumnExists, ColumnIdentifier columnName, ColumnConstraints.Raw constraints)\n        {\n            super(keyspaceName, tableName, ifTableExists);\n            this.columnName = columnName;\n            this.constraints = constraints;\n            this.ifColumnExists = ifColumnExists;\n        }","sourceCodeStart":801,"sourceCodeEnd":837,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/cql3/statements/schema/AlterTableStatement.java#L801-L837","documentation":"Cassandra refuses to drop COMPACT STORAGE when some nodes in the cluster still hold non-upgraded 2.x-format SSTables. DROPPING COMPACT STORAGE rewrites the table layout, and the schema change is only safe if every node has fully upgraded its on-disk data. The check collects the set of nodes reported via gossip/SSTable versions and rejects the ALTER TABLE if any node still has 2.x sstables.","triggerScenarios":"Running `ALTER TABLE ... DROP COMPACT STORAGE` on a cluster where at least one node still has 2.x sstables (reported as with2xSStables), typically after a rolling upgrade where `nodetool upgradesstables` was not run on all nodes.","commonSituations":"Mixed-version rolling upgrades (2.x -> 3.x/4.x); nodes that were upserted with old snapshots or backups containing 2.x sstables; forgetting `nodetool upgradesstables` after upgrading; restored data directories with pre-upgrade sstables.","solutions":["On every node listed in the error message, run `nodetool upgradesstables` so all 2.x sstables are rewritten to the current format.","Verify with `nodetool tablestats` / sstable metadata (sstable version in `find *.db` metadata or `nodetool info`) that no 2.x sstables remain.","Retry the `ALTER TABLE ... DROP COMPACT STORAGE` statement once all nodes report upgraded sstables.","If stale sstables are unneeded (e.g. old snapshots), remove snapshots/compact so upgradesstables can eliminate them."],"exampleFix":"// before (fails on mixed cluster)\nALTER TABLE myks.mytable DROP COMPACT STORAGE;\n\n// after: on each listed node first\n$ nodetool upgradesstables\n// then\nALTER TABLE myks.mytable DROP COMPACT STORAGE;","handlingStrategy":"validation","validationCode":"// before running DROP COMPACT STORAGE, check per node:\n// nodetool tablestats <table> | grep -i sstable   and check sstable versions via\n// nodetool upgradesstables (idempotent) ; only proceed once upgrades complete\nString out = exec(\"nodetool upgradesstables\");\nif (clusterHas2xSStables()) throw new IllegalStateException(\"run upgradesstables on all nodes first\");","typeGuard":null,"tryCatchPattern":"try { session.execute(\"ALTER TABLE ks.t DROP COMPACT STORAGE\"); }\ncatch (com.datastax.driver.core.exceptions.InvalidQueryException e) {\n  if (e.getMessage().contains(\"non-upgraded 2.x sstables\")) scheduleUpgradesstablesOnListedNodes(e.getMessage());\n  else throw e;\n}","preventionTips":["Always run `nodetool upgradesstables` as a standard post-upgrade step on every node","After restoring backups/snapshots, re-run upgradesstables before schema changes","During rolling upgrades, defer DROP COMPACT STORAGE until the whole cluster is on the new version and data is rewritten"],"tags":["cassandra","schema-change","upgrade","storage"],"backgroundTag":"invalid-state-transition","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}