{"record":{"id":"bbe8d4f04022195d","repo":"apache/cassandra","slug":"failed-to-load-bloom-filter-for-sstable","errorCode":null,"errorMessage":"Failed to load Bloom filter for SSTable: ","messagePattern":"Failed to load Bloom filter for SSTable: ","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/io/sstable/format/FilterComponent.java","lineNumber":69,"sourceCode":"     * Load bloom filter from Filter.db file.\n     */\n    public static IFilter load(Descriptor descriptor) throws IOException\n    {\n        File filterFile = descriptor.fileFor(Components.FILTER);\n\n        if (!filterFile.exists())\n            return null;\n\n        if (filterFile.length() == 0)\n            return FilterFactory.AlwaysPresent;\n\n        try (FileInputStreamPlus stream = descriptor.fileFor(Components.FILTER).newInputStream())\n        {\n            return BloomFilterSerializer.forVersion(descriptor.version.hasOldBfFormat()).deserialize(stream);\n        }\n        catch (IOException ex)\n        {\n            throw new IOException(\"Failed to load Bloom filter for SSTable: \" + descriptor.baseFile(), ex);\n        }\n    }\n\n    public static void save(IFilter filter, Descriptor descriptor, boolean deleteOnFailure) throws IOException\n    {\n        File filterFile = descriptor.fileFor(Components.FILTER);\n        try (FileOutputStreamPlus stream = filterFile.newOutputStream(File.WriteMode.OVERWRITE))\n        {\n            filter.serialize(stream, descriptor.version.hasOldBfFormat());\n            stream.flush();\n            stream.sync();\n        }\n        catch (IOException ex)\n        {\n            if (deleteOnFailure)\n                descriptor.fileFor(Components.FILTER).deleteIfExists();\n            throw new IOException(\"Failed to save Bloom filter for SSTable: \" + descriptor.baseFile(), ex);\n        }","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/io/sstable/format/FilterComponent.java#L51-L87","documentation":"FilterComponent.load reads an SSTable's filter component and deserializes its Bloom filter. If the read or deserialization throws IOException, it is rethrown with 'Failed to load Bloom filter for SSTable: <baseFile>' and the original cause attached, identifying which SSTable's Bloom filter could not be loaded.","triggerScenarios":"Opening an SSTable whose Filter.db file is unreadable: missing/truncated filter file, corrupt Bloom filter bytes (checksum mismatch), wrong bf format for the descriptor version, or I/O error on the underlying stream.","commonSituations":"Filter.db lost during incomplete restores; disk corruption; mixing SSTables between Cassandra versions with different Bloom filter formats (hasOldBfFormat mismatch); out-of-space reads.","solutions":["Restore Filter.db from a snapshot/backup, or delete the corrupt filter component so the SSTable can rebuild/use a dummy filter, then run scrub","Run sstablescrub / nodetool scrub on the table to regenerate or quarantine the bad filter component","Confirm the SSTable came from a compatible Cassandra version (Bloom filter format changed historically); recompact or re-stream from replicas if not","Check disk health and permissions on the SSTable directory"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"File filterFile = descriptor.fileFor(Component.FILTER);\nif (!filterFile.exists() || filterFile.length() == 0)\n    throw new IOException(\"Filter component missing/empty for \" + descriptor);","typeGuard":null,"tryCatchPattern":"try { filter = FilterComponent.load(descriptor); }\ncatch (IOException e) {\n    logger.warn(\"Bloom filter unusable for {}: {}\", descriptor.baseFile(), e.getMessage());\n    // fall back to a dummy filter (all probes positive) and scrub the SSTable\n    filter = BloomFilterFactory.alwaysPresentingFilter();\n}","preventionTips":["Copy full snapshots so Filter.db is never left behind","Pin the whole cluster to one Cassandra version (bf format compatibility)","Run scrub periodically to catch corrupt components early","Verify filter file non-empty after restores"],"tags":["sstable","bloom-filter","corruption","io"],"backgroundTag":"file-read-failed","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"}