{"record":{"id":"04c723999ff60e21","repo":"MyCATApache/Mycat-Server","slug":"load-crc32slot-datafile-error-dn-k-value-range","errorCode":null,"errorMessage":"load crc32slot datafile error:dn={k},value={range}","messagePattern":"load crc32slot datafile error:dn=(.+?),value=(.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/main/java/io/mycat/route/function/PartitionByCRC32PreSlot.java","lineNumber":140,"sourceCode":"    private Map<Integer, List<Range>> convertToMap(Properties p) {\n        Map<Integer, List<Range>> map = new TreeMap<>();\n        for (Object o : p.keySet()) {\n            String k = (String) o;\n            String v = p.getProperty(k);\n            List<String> ranges = Splitter.on(\",\").omitEmptyStrings().trimResults().splitToList(v);\n            List<Range> rangeList = new ArrayList<>();\n            for (String range : ranges) {\n                List<String> vv = Splitter.on(\"-\").omitEmptyStrings().trimResults().splitToList(range);\n                if (vv.size() == 2) {\n                    Range ran = new Range(Integer.parseInt(vv.get(0)), Integer.parseInt(vv.get(1)));\n                    rangeList.add(ran);\n\n                } else if (vv.size() == 1) {\n                    Range ran = new Range(Integer.parseInt(vv.get(0)), Integer.parseInt(vv.get(0)));\n                    rangeList.add(ran);\n\n                } else {\n                    throw new RuntimeException(\"load crc32slot datafile error:dn=\" + k + \",value=\" + range);\n                }\n            }\n            map.put(Integer.parseInt(k), rangeList);\n        }\n\n        return map;\n    }\n\n    @Override\n    public void init() {\n\n        super.init();\n        if (ruleName != null) {\n            Properties p = loadProps(ruleName, false);\n            rangeMap = convertToMap(p);\n            checkSize();\n            hack();\n        }","sourceCodeStart":122,"sourceCodeEnd":158,"githubUrl":"https://github.com/MyCATApache/Mycat-Server/blob/65f8d8beb752f935752f2a0eec0ab017facab9ef/src/main/java/io/mycat/route/function/PartitionByCRC32PreSlot.java#L122-L158","documentation":"PartitionByCRC32PreSlot.convertToMap parses the crc32slot data file where each node's 'value' string lists slot ranges. A node entry with more than one element in its parsed range list (vv.size() > 1) is unexpected for this format, so a RuntimeException 'load crc32slot datafile error:dn=...,value=...' is thrown, failing rule init/reinit.","triggerScenarios":"init/reInit -> convertToMap reads the slot mapping file (rule data file, e.g. rule.xml partition-by-crc32pre-slot data file) and a dn line contains multiple range tokens instead of a single start-end pair or single value.","commonSituations":"Data file manually edited or corrupted; file produced by a different mycat/migration tool version with a divergent format; partial write during migration crash leaving malformed lines; mixing formats from reInit with stale content.","solutions":["Inspect the data file line for the offending dn and fix it to the expected format: each value either 'start-end' or a single integer.","Regenerate the slot data file with the mycat migration tooling (re-run the expansion/migration analysis) instead of hand-editing.","Restore the file from a backup taken before the migration started.","Ensure the mycat version reading the file matches the version that wrote it; upgrade both consistently and re-init."],"exampleFix":"// before (datafile line)\n0=1-100,200-300\n// after\n0=1-100","handlingStrategy":"validation","validationCode":"for (String line : Files.readAllLines(dataFile)) {\n    String value = line.substring(line.indexOf('=') + 1);\n    boolean ok = value.matches(\"\\\\d+(-\\\\d+)?\");\n    if (!ok) throw new IllegalStateException(\"malformed slot line: \" + line);\n}","typeGuard":null,"tryCatchPattern":"try {\n    rule.init(cfg);\n} catch (RuntimeException e) {\n    if (e.getMessage().startsWith(\"load crc32slot datafile error\")) {\n        LOGGER.error(\"regenerate or restore crc32slot datafile\");\n    } else { throw e; }\n}","preventionTips":["Never hand-edit crc32slot data files; regenerate with the migration tool","Back up data files before expansions/migrations","Keep mycat and migration tooling versions aligned"],"tags":["crc32slot","datafile","parse-error","migration"],"backgroundTag":"invalid-config-value","analyzedSha":"65f8d8beb752f935752f2a0eec0ab017facab9ef","analyzedAt":"2026-09-11T00:12:21.696Z","contentChangedAt":"2026-09-11T00:12:21.696Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}