{"record":{"id":"c2599aed7c9c3d9b","repo":"apache/cassandra","slug":"drop-compact-storage-is-disabled-enable-in-cassan","errorCode":null,"errorMessage":"DROP COMPACT STORAGE is disabled. Enable in cassandra.yaml to use.","messagePattern":"DROP COMPACT STORAGE is disabled\\. Enable in cassandra\\.yaml to use\\.","errorType":"validation","errorClass":"InvalidRequestException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/cql3/statements/schema/AlterTableStatement.java","lineNumber":740,"sourceCode":"    private static class DropCompactStorage extends AlterTableStatement\n    {\n        private static final Logger logger = LoggerFactory.getLogger(AlterTableStatement.class);\n        private static final NoSpamLogger noSpamLogger = NoSpamLogger.getLogger(logger, 5L, TimeUnit.MINUTES);\n        private DropCompactStorage(String keyspaceName, String tableName, boolean ifTableExists)\n        {\n            super(keyspaceName, tableName, ifTableExists);\n        }\n\n        @Override\n        public boolean compatibleWith(ClusterMetadata metadata)\n        {\n            return metadata.directory.commonSerializationVersion.isAtLeast(Version.V0);\n        }\n\n        public KeyspaceMetadata apply(Epoch epoch, KeyspaceMetadata keyspace, TableMetadata table, ClusterMetadata metadata)\n        {\n            if (!DatabaseDescriptor.enableDropCompactStorage())\n                throw new InvalidRequestException(\"DROP COMPACT STORAGE is disabled. Enable in cassandra.yaml to use.\");\n\n            if (!table.isCompactTable())\n                throw AlterTableStatement.ire(\"Cannot DROP COMPACT STORAGE on table without COMPACT STORAGE\");\n\n            validateCanDropCompactStorage();\n\n            Set<Flag> flags = table.isCounter()\n                            ? ImmutableSet.of(Flag.COMPOUND, Flag.COUNTER)\n                            : ImmutableSet.of(Flag.COMPOUND);\n\n            return keyspace.withSwapped(keyspace.tables.withSwapped(table.unbuild().flags(flags).build()));\n        }\n\n        /**\n         * Throws if DROP COMPACT STORAGE cannot be used (yet) because the cluster is not sufficiently upgraded. To be able\n         * to use DROP COMPACT STORAGE, we need to ensure that no pre-3.0 sstables exists in the cluster, as we won't be\n         * able to read them anymore once COMPACT STORAGE is dropped (see CASSANDRA-15897). In practice, this method checks\n         * 3 things:","sourceCodeStart":722,"sourceCodeEnd":758,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/cql3/statements/schema/AlterTableStatement.java#L722-L758","documentation":"DROP COMPACT STORAGE is a destructive, once-only schema operation gated behind a cassandra.yaml flag (enable_drop_compact_storage). If the flag is not enabled, the ALTER TABLE ... DROP COMPACT STORAGE statement fails immediately with this InvalidRequestException, protecting operators from accidental data-layout rewrites.","triggerScenarios":"Executing `ALTER TABLE ks.tbl DROP COMPACT STORAGE;` on a node where cassandra.yaml does not set `enable_drop_compact_storage: true`.","commonSituations":"Post-3.x upgrade cleanup: operators migrating thrift-era COMPACT STORAGE tables to 4.0 syntax but forgetting the yaml flag (default false), often hit during scripted migrations.","solutions":["Set `enable_drop_compact_storage: true` in cassandra.yaml on the node and restart, then retry the ALTER TABLE.","Enable it temporarily only for the migration window and disable afterwards to prevent accidental drops.","Verify the table is actually a compact table (`table.isCompactTable()`) — otherwise the flag change is pointless.","Take a snapshot before running DROP COMPACT STORAGE."],"exampleFix":"// before (cassandra.yaml)\nenable_drop_compact_storage: false\n// after\nenable_drop_compact_storage: true\n// then restart node and run:\n// ALTER TABLE ks.tbl DROP COMPACT STORAGE;","handlingStrategy":"validation","validationCode":"boolean enabled = StorageService.instance.isDropCompactStorageEnabled(); if (!enabled) throw new IllegalStateException(\"set enable_drop_compact_storage: true in cassandra.yaml and restart first\");","typeGuard":null,"tryCatchPattern":"try { session.execute(\"ALTER TABLE ks.tbl DROP COMPACT STORAGE\"); } catch (InvalidRequestException e) { if (e.getMessage().contains(\"DROP COMPACT STORAGE is disabled\")) { enableFlagAndRestart(); retry(); } else throw e; }","preventionTips":["Check cassandra.yaml for enable_drop_compact_storage before migration scripts","Enable the flag only during a controlled migration window","Snapshot tables before DROP COMPACT STORAGE"],"tags":["cql","compact-storage","feature-flag","configuration"],"backgroundTag":"feature-not-enabled","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"}