{"record":{"id":"8bd44638025755ac","repo":"MyCATApache/Mycat-Server","slug":"fetch-param-values-error","errorCode":null,"errorMessage":"fetch Param Values error.","messagePattern":"fetch Param Values error\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/main/java/io/mycat/route/sequence/handler/IncrSequenceHandler.java","lineNumber":60,"sourceCode":"\n\tpublic static final String FILE_NAME = \"sequence_conf.properties\";\n\n\tpublic static final String KEY_HIS_NAME = \".HISIDS\";// 1-10000,50001-60000\n\tpublic static final String KEY_MIN_NAME = \".MINID\";// 1\n\tpublic static final String KEY_MAX_NAME = \".MAXID\";// 10000\n\tpublic static final String KEY_CUR_NAME = \".CURID\";// 888\n\n\tpublic abstract Map<String, String> getParaValMap(String prefixName);\n\n\tpublic abstract Boolean updateCURIDVal(String prefixName, Long val);\n\n\tpublic abstract Boolean fetchNextPeriod(String prefixName);\n\n\t@Override\n\tpublic long nextId(String prefixName) {\n\t\tMap<String, String> paraMap = this.getParaValMap(prefixName);\n\t\tif (null == paraMap) {\n\t\t\tthrow new RuntimeException(\"fetch Param Values error.\");\n\t\t}\n\t\tLong nextId = Long.parseLong(paraMap.get(prefixName + KEY_CUR_NAME)) + 1;\n\t\tLong maxId = Long.parseLong(paraMap.get(prefixName + KEY_MAX_NAME));\n\t\tif (nextId > maxId) {\n\t\t\tfetchNextPeriod(prefixName);\n\t\t\treturn nextId(prefixName);\n\t\t}\n\t\tupdateCURIDVal(prefixName, nextId);\n\t\treturn nextId.longValue();\n\n\t}\n}","sourceCodeStart":42,"sourceCodeEnd":72,"githubUrl":"https://github.com/MyCATApache/Mycat-Server/blob/65f8d8beb752f935752f2a0eec0ab017facab9ef/src/main/java/io/mycat/route/sequence/handler/IncrSequenceHandler.java#L42-L72","documentation":"IncrSequenceHandler.nextId retrieves the parameter value map for the given prefix (the sequence's current/max values, typically fetched from a store such as ZooKeeper or DB). If the map comes back null, meaning the handler could not load the sequence's parameters at all, it throws this RuntimeException instead of returning an ID. The failure is usually a symptom of the underlying storage fetch (getParaValMap implementation) failing or the sequence prefix not existing there.","triggerScenarios":"Calling nextId(prefixName) where getParaValMap(prefixName) returns null — i.e. the configured sequence prefix has no entry in the backing store, the store is unreachable/returns an error, or the fetch timed out and the implementation signals failure with null.","commonSituations":"sequence_conf/sequence store missing the requested prefix name; ZooKeeper or DB connectivity problems; wrong prefix (table name) passed to nextId; environment/cluster misconfiguration after failover.","solutions":["Verify the sequence prefix exists in the backing store (e.g. ZooKeeper node or sequence DB table) and that getParaValMap can read it for that exact name.","Check connectivity and credentials of the store used by the concrete handler (DB user, ZK quorum) and retry after restoring the connection.","Check server logs/MyCat configuration (sequence handler type and prefix settings) for a mismatch between the app's sequence name and the configured one.","Wrap nextId calls with retry/fallback logic, since transient store outages surface as this error."],"exampleFix":"// before\nlong id = incrSequenceHandler.nextId(\"ORDER_SEQ\");\n// after\ntry {\n    long id = incrSequenceHandler.nextId(\"ORDER_SEQ\");\n} catch (RuntimeException e) {\n    if (e.getMessage() != null && e.getMessage().startsWith(\"fetch Param Values error\")) {\n        // check ZK/DB store for ORDER_SEQ entry, then retry\n    }\n    throw e;\n}","handlingStrategy":"retry","validationCode":"public static boolean sequenceParamsAvailable(IncrSequenceHandler h, String prefix) {\n    try {\n        return h.getParaValMap(prefix) != null; // or a read-only existence check on the store\n    } catch (Exception e) { return false; }\n}","typeGuard":"if (paraMap == null || !paraMap.containsKey(prefix + KEY_CUR_NAME)\n        || !paraMap.containsKey(prefix + KEY_MAX_NAME)) {\n    throw new IllegalStateException(\"sequence parameters unavailable for \" + prefix);\n}","tryCatchPattern":"try {\n    return handler.nextId(prefixName);\n} catch (RuntimeException e) {\n    if (\"fetch Param Values error.\".equals(e.getMessage())) {\n        waitForStoreRecovery();\n        return handler.nextId(prefixName); // one bounded retry\n    }\n    throw e;\n}","preventionTips":["Ensure every sequence prefix used by apps is provisioned in the backing store (ZK/DB) before deployment.","Monitor store connectivity (ZK quorum, sequence DB) and alert on failures.","Use exact, case-correct sequence names; centralize them in constants/config.","Add bounded retry with backoff around ID generation for transient store outages."],"tags":["sequence","id-generation","null-result","storage-fetch"],"backgroundTag":"database-query-failed","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"}