{"record":{"id":"0140c9ab6531f9e0","repo":"apache/cassandra","slug":"error-loading-counter-cache","errorCode":null,"errorMessage":"Error loading counter cache","messagePattern":"Error loading counter cache","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/java/org/apache/cassandra/service/StorageService.java","lineNumber":849,"sourceCode":"                                    ClusterMetadataService.state() != ClusterMetadataService.State.GOSSIP); // only populate local state if not running in gossip mode\n        }\n\n        Gossiper.instance.register(this);\n        Gossiper.instance.addLocalApplicationState(ApplicationState.NET_VERSION, valueFactory.networkVersion());\n        Gossiper.instance.addLocalApplicationState(ApplicationState.SSTABLE_VERSIONS,\n                                                   valueFactory.sstableVersions(sstablesTracker.versionsInUse()));\n\n        Gossiper.instance.triggerRoundWithCMS();\n\n        // Has to be called after the host id has potentially changed\n        try\n        {\n            CacheService.instance.counterCache.loadSavedAsync().get();\n        }\n        catch (Throwable t)\n        {\n            JVMStabilityInspector.inspectThrowable(t);\n            logger.warn(\"Error loading counter cache\", t);\n        }\n        Gossiper.waitToSettle();\n\n        NodeId self = Register.maybeRegister();\n        if (!AccordService.isSetupOrStarting())\n            AccordService.localStartup(self);\n        AccordService.distributedStartup();\n\n        RegistrationStatus.instance.onRegistration();\n        Startup.maybeExecuteStartupTransformation(self);\n\n        if (CassandraRelevantProperties.SYNC_SYSTEM_PEERS_TABLES_AT_STARTUP.getBoolean())\n            SystemPeersValidator.validateAndRepair(ClusterMetadata.current());\n\n        try\n        {\n            if (joinRing)\n                joinRing();","sourceCodeStart":831,"sourceCodeEnd":867,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/service/StorageService.java#L831-L867","documentation":"WARN from StorageService.initServer() when loading the saved counter cache (CacheService.instance.counterCache.loadSavedAsync().get()) fails. The original Throwable is passed to JVMStabilityInspector.inspectThrowable to decide whether it is fatal (e.g. disk corruption may halt the JVM), and if execution continues the node starts without a warmed counter cache — counters still work but the cache rebuilds cold.","triggerScenarios":"initServer() startup path where counter cache files in saved_caches are unreadable, corrupt, or an IO/runtime exception occurs during async load; .get() rethrows the loading failure.","commonSituations":"Corrupted or truncated saved_caches files after an unclean shutdown or disk failure; permission problems on the saved_caches directory; restoring a node from backup without cache files.","solutions":["Read the attached stack trace; if JVMStabilityInspector flagged disk errors, address disk health first.","Delete the counter cache files under the saved_caches directory (safe — cache rebuilds automatically) and restart.","Check directory permissions/ownership for the cassandra user on saved_caches.","Verify disk space and filesystem integrity (dmesg, fsck) if corruption repeats.","Optionally disable the counter cache (counter_cache_save_period: 0) if counters are not used."],"exampleFix":"# before: corrupted cache blocks startup behavior\nls /var/lib/cassandra/saved_caches/\n# after: remove stale cache files and restart\nrm /var/lib/cassandra/saved_caches/CounterCache-*\nsystemctl restart cassandra","handlingStrategy":"try-catch","validationCode":"// preflight: check saved_caches dir readable and not corrupted\nFile dir = new File(DatabaseDescriptor.getSavedCachesLocation());\nif (!dir.canRead()) logger.warn(\"saved_caches unreadable: {}\", dir);","typeGuard":null,"tryCatchPattern":"try {\n    CacheService.instance.counterCache.loadSavedAsync().get();\n} catch (Throwable t) {\n    JVMStabilityInspector.inspectThrowable(t);\n    logger.warn(\"Error loading counter cache\", t);\n}","preventionTips":["Monitor saved_caches directory permissions and disk health.","After unclean shutdowns, proactively clear cache files before restart.","Disable counter cache saving if counters are unused."],"tags":["cassandra","startup","cache","disk"],"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"}