{"record":{"id":"7d9d2e28d2fa1b06","repo":"apache/cassandra","slug":"invalid-columns-subset-bytes-too-many-bits-set-e","errorCode":null,"errorMessage":"Invalid Columns subset bytes; too many bits set:<encoded>","messagePattern":"Invalid Columns subset bytes; too many bits set:<encoded>","errorType":"exception","errorClass":"java.io.IOException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/db/Columns.java","lineNumber":601,"sourceCode":"                return deserializeLargeSubset(in, superset, (int) encoded);\n            }\n            else\n            {\n                try (BTree.FastBuilder<ColumnMetadata> builder = BTree.fastBuilder())\n                {\n                    int firstComplexIdx = 0;\n                    for (ColumnMetadata column : superset)\n                    {\n                        if ((encoded & 1) == 0)\n                        {\n                            builder.add(column);\n                            if (column.isSimple())\n                                ++firstComplexIdx;\n                        }\n                        encoded >>>= 1;\n                    }\n                    if (encoded != 0)\n                        throw new IOException(\"Invalid Columns subset bytes; too many bits set:\" + Long.toBinaryString(encoded));\n                    return new Columns(builder.build(), firstComplexIdx);\n                }\n            }\n        }\n\n        // encodes a 1 bit for every *missing* column, on the assumption presence is more common,\n        // and because this is consistent with encoding 0 to represent all present\n        private static long encodeBitmap(Collection<ColumnMetadata> columns, Columns superset, int supersetCount)\n        {\n            long bitmap = 0L;\n            BTreeSearchIterator<ColumnMetadata, ColumnMetadata> iter = superset.iterator();\n            // the index we would encounter next if all columns are present\n            int expectIndex = 0;\n            for (ColumnMetadata column : columns)\n            {\n                if (iter.next(column) == null)\n                    throw new IllegalStateException(columns + \" is not a subset of \" + superset);\n","sourceCodeStart":583,"sourceCodeEnd":619,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/db/Columns.java#L583-L619","documentation":"Thrown by Columns.Serializer.deserializeSubset when decoding a bitmap-encoded column subset: after consuming all known columns, leftover bits remain set in the encoded long. The bitmap encodes more present columns than the serialized subset actually contains, so the payload is corrupt or was written by an incompatible serialization version.","triggerScenarios":"Deserializing a SerializedMarker/subset payload where the 64-bit presence bitmap has bits set beyond the columns consumed; usually on-disk or inter-node payload corruption or a version mismatch between writer and reader.","commonSituations":"Bit-flip disk corruption; reading a data file or hinted payload produced by a different Cassandra version with a changed Columns encoding; restoring partial/mixed SSTables.","solutions":["Identify and repair the affected SSTables (nodetool scrub) and run a repair to restore correct data from replicas.","Verify all nodes run a compatible Cassandra version before/while upgrading; finish rolling upgrades consistently.","Check disk health (SMART, filesystem errors) on the node reporting the error.","If it reproduces deterministically, capture the payload and file a bug with the Cassandra project."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"catch (IOException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"Invalid Columns subset bytes\")) {\n        // corrupt payload: fail over to another replica / trigger repair\n        retryOnOtherReplica();\n        scheduleRepair();\n    } else throw e;\n}","preventionTips":["Keep all nodes on a compatible Cassandra version during rolling upgrades.","Monitor disk health and enable checksums (end-to-end integrity is default in modern formats).","Run regular nodetool scrub and repair.","Avoid restoring SSTables copied from mixed-version clusters."],"tags":["cassandra","deserialization","corruption","bitmap"],"backgroundTag":"checksum-mismatch","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"}