{"record":{"id":"bfd2092fe933bbef","repo":"apache/cassandra","slug":"dictionary-to-import-has-older-dictionary-id-s","errorCode":null,"errorMessage":"Dictionary to import has older dictionary id (%s) than the latest compression dictionary (%s) for table %s.%s","messagePattern":"Dictionary to import has older dictionary id \\((.+?)\\) than the latest compression dictionary \\((.+?)\\) for table (.+?)\\.(.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/db/compression/CompressionDictionaryManager.java","lineNumber":296,"sourceCode":"                                                      keyspaceName, tableName));\n\n        CompressionDictionary.Kind kind = CompressionDictionary.Kind.valueOf(dataObject.kind);\n\n        if (this.kind != kind)\n        {\n            throw new IllegalArgumentException(format(\"It is not possible to import compression dictionaries of kind \" +\n                                                      \"%s into table %s.%s which supports compression dictionaries of kind %s.\",\n                                                      kind, keyspaceName, tableName, this.kind));\n        }\n\n        CompressionDictionary.DictId dictId = new CompressionDictionary.DictId(kind, dataObject.dictId);\n\n        LightweightCompressionDictionary latestCompressionDictionary = retrieveLightweightLatestCompressionDictionary(keyspaceName, tableName, tableId);\n        if (latestCompressionDictionary != null)\n        {\n            if (latestCompressionDictionary.dictId.id > dictId.id)\n            {\n                throw new IllegalArgumentException(format(\"Dictionary to import has older dictionary id (%s) than the latest compression dictionary (%s) for table %s.%s\",\n                                                          dictId.id, latestCompressionDictionary.dictId.id, keyspaceName, tableName));\n            }\n\n            checkTrainingFrequency(latestCompressionDictionary, createTrainingConfig(Map.of()));\n        }\n\n        handleNewDictionary(kind.createDictionary(dictId, dataObject.dict, dataObject.dictChecksum));\n    }\n\n    /**\n     * Close all the resources. The method can be called multiple times.\n     */\n    @Override\n    public synchronized void close()\n    {\n        unregisterMbean();\n        closeQuitely(cache, \"CompressionDictionaryCache\");\n        closeQuitely(scheduler, \"CompressionDictionaryScheduler\");","sourceCodeStart":278,"sourceCodeEnd":314,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/db/compression/CompressionDictionaryManager.java#L278-L314","documentation":"Dictionaries are versioned by a monotonically increasing dictId. importCompressionDictionary() rejects an import whose dictId is older than the latest dictionary already active on the table, throwing IllegalArgumentException, to avoid regressing compression quality by rolling back to an obsolete dictionary.","triggerScenarios":"Calling importCompressionDictionary with a payload whose dictId.id is less than retrieveLightweightLatestCompressionDictionary(...).dictId.id — i.e. re-importing an old exported dictionary after a newer one was trained or imported.","commonSituations":"Replaying old export files into a cluster that has since trained a newer dictionary; importing dictionaries out of order across multiple nodes; restoring a snapshot dictionary from before a more recent training run.","solutions":["Export and import the latest dictionary (highest dictId) for the table.","Skip the import if the target already has a dictionary with an equal or higher dictId.","Retrain to produce a fresh dictionary if only old exports are available.","Check the current latest dictId via the manager's JMX attributes before importing."],"exampleFix":"// before\nmanager.importCompressionDictionary(oldDictionaryData); // dictId 3 < current 5\n// after\nif (currentLatestDictId <= dictionaryData.dictId)\n    manager.importCompressionDictionary(dictionaryData);","handlingStrategy":"validation","validationCode":"long latest = manager.getLatestDictionaryId();\nif (dataObject.dictId >= latest) manager.importCompressionDictionary(data);","typeGuard":null,"tryCatchPattern":"try { manager.importCompressionDictionary(data); } catch (IllegalArgumentException e) { /* stale dictionary: fetch the newest export */ }","preventionTips":["Always import the newest export (highest dictId)","Track export dictIds in automation and skip stale ones","Re-export after any training run"],"tags":["compression","dictionary-import","versioning"],"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"}