{"record":{"id":"0445e6b0fe79a807","repo":"apache/cassandra","slug":"not-yet-initialized-can-t-load-new-sstables","errorCode":null,"errorMessage":"Not yet initialized, can't load new sstables","messagePattern":"Not yet initialized, can't load new sstables","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/service/StorageService.java","lineNumber":4593,"sourceCode":"            }\n        };\n\n        return new SSTableLoader(dir, client, new OutputHandler.LogOutput()).stream();\n    }\n\n    public void rescheduleFailedDeletions()\n    {\n        LifecycleTransaction.rescheduleFailedDeletions();\n    }\n\n    /**\n     * @deprecated See CASSANDRA-14417\n     */\n    @Deprecated(since = \"4.0\")\n    public void loadNewSSTables(String ksName, String cfName)\n    {\n        if (!isInitialized())\n            throw new RuntimeException(\"Not yet initialized, can't load new sstables\");\n        Keyspace.verifyKeyspaceIsValid(ksName);\n        ColumnFamilyStore.loadNewSSTables(ksName, cfName);\n    }\n\n    /**\n     * #{@inheritDoc}\n     */\n    public List<String> sampleKeyRange() // do not rename to getter - see CASSANDRA-4452 for details\n    {\n        List<DecoratedKey> keys = new ArrayList<>();\n        for (Keyspace keyspace : Keyspace.nonLocalStrategy())\n        {\n            if (keyspace.getMetadata().params.replication.isMeta())\n                continue;\n            for (Range<Token> range : getPrimaryRangesForEndpoint(keyspace.getName(), getBroadcastAddressAndPort()))\n                keys.addAll(keySamples(keyspace.getColumnFamilyStores(), range));\n        }\n","sourceCodeStart":4575,"sourceCodeEnd":4611,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/service/StorageService.java#L4575-L4611","documentation":"StorageService.loadNewSSTables() is a deprecated public entry point (CASSANDRA-14417) for bulk-loading existing SSTables into a table. The node throws this RuntimeException when the StorageService has not finished full startup/initialization (isInitialized() returns false), because sstable loading requires the ring, schema, and storage services to be up.","triggerScenarios":"Calling StorageService.loadNewSSTables(ksName, cfName) programmatically or via JMX/nodetool before the node has completed initialization (e.g., during startup, while still in STARTING state, or on an uninitialized embedded instance).","commonSituations":"Automation scripts or JMX clients firing loadNewSSTables too early after a node restart; embedded/test harnesses invoking the API before StorageService.initServer(); monitoring tools racing node boot.","solutions":["Wait until the node is fully initialized before calling loadNewSSTables (poll StorageService.isInitialized() or check nodetool status returns normally).","Retry the call after startup completes; wrap in a loop that waits for isInitialized().","Use the JMX notification for 'Started' state or StorageService operation mode == NORMAL as the readiness signal.","Prefer letting the node's own startup sstable scan handle the files instead of the deprecated loadNewSSTables API."],"exampleFix":"// before\nstorageService.loadNewSSTables(\"ks\", \"tbl\"); // throws if not initialized\n// after\nif (!storageService.isInitialized()) {\n    throw new IllegalStateException(\"wait for node startup before loading sstables\");\n}\nstorageService.loadNewSSTables(\"ks\", \"tbl\");","handlingStrategy":"validation","validationCode":"if (!storageService.isInitialized()) { throw new IllegalStateException(\"node not ready; retry after startup\"); }\nstorageService.loadNewSSTables(ksName, cfName);","typeGuard":"boolean ready = java.util.Optional.ofNullable(storageService).map(s -> s.isInitialized()).orElse(false);","tryCatchPattern":"try { storageService.loadNewSSTables(ks, cf); } catch (RuntimeException e) { if (!storageService.isInitialized()) { /* retry after startup */ } else { throw e; } }","preventionTips":["Gate any loadNewSSTables call on StorageService.isInitialized() or operation mode NORMAL.","Prefer letting startup's sstable scan pick up files instead of the deprecated API.","Add readiness checks to automation before JMX operations.","Track CASSANDRA-14417: this API is deprecated."],"tags":["runtime","initialization","jmx","deprecated"],"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"}