{"record":{"id":"f7a4b59461daf31c","repo":"MyCATApache/Mycat-Server","slug":"fetching-sequence-can-not-support-the-db-driver-d","errorCode":null,"errorMessage":"fetching sequence can not support the db driver:{dbDriver}","messagePattern":"fetching sequence can not support the db driver:(.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/main/java/io/mycat/route/sequence/handler/SequenceVal.java","lineNumber":86,"sourceCode":"\t *1.后端获取序列\n\t *  如果返回的结果为超时，异常，尝试数据库重试获取\n\t *     返回的为0，0   尝试数据库重试获取\n\t *     结果还未返回，调用函数继续等待\n\t *  成功返回则正常返回\n\t * */\n\n\tpublic Long[] fetchSequenceFromDB(FetchMySQLSequnceHandler mysqlSeqFetcher, int retryCount, boolean canSendFetch) {\n\t\tDataHostConfig dataHostConfig = getDBHostConfig();\n\n\t\tif (dataHostConfig.isJDBCDriver()) {\n\t\t\treturn getSequenceValueByJDBC(retryCount);\n\t\t}\n\n\t\tif (dataHostConfig.isNativeDriver()) {\n\t\t\treturn getSequenceByNaitve(mysqlSeqFetcher, retryCount, canSendFetch);\n\t\t}\n\n\t\tthrow new RuntimeException(\"fetching sequence can not support the db driver:\" + dataHostConfig.getDbDriver());\n\t}\n\n\tprivate Long[] getSequenceByNaitve(FetchMySQLSequnceHandler mysqlSeqFetcher, int retryCount, boolean canSendFetch) {\n\t\tfinal int systemRetryCount = MycatServer.getInstance().getConfig().getSystem().getSequnceMySqlRetryCount();\n\t\t//进入waitFinish小于4次，或者可以后端获取数据\n\t\tif(retryCount <= systemRetryCount && canSendFetch) {\n\n\t\t\tthis.reset();\n\t\t\tmysqlSeqFetcher.execute(this);\n\t\t} else if(retryCount > systemRetryCount){\n\t\t\tfetching.compareAndSet(true, false); //\n\t\t\treturn null;\n\t\t}\n\t\tlong start = System.currentTimeMillis();\n\t\t//直接等待\n\t\tlong mysqlWaitTime = MycatServer.getInstance().getConfig().getSystem().getSequnceMySqlWaitTime();\n\n\t\tlong end = start + mysqlWaitTime;","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/MyCATApache/Mycat-Server/blob/65f8d8beb752f935752f2a0eec0ab017facab9ef/src/main/java/io/mycat/route/sequence/handler/SequenceVal.java#L68-L104","documentation":"SequenceVal.fetchSequenceFromDB only implements sequence fetching through the native MySQL fetcher (used when the data host is configured with the native MySQL driver). If the data host's dbDriver is anything other than the native/MySQL driver, it throws a RuntimeException because no fetcher exists for that driver.","triggerScenarios":"A global sequence of type 1 (database sequence) configured against a dataHost whose dbDriver is not mysql native (e.g. JDBC driver set to something else in schema.xml/dataHost config).","commonSituations":"Deploying Mycat against PostgreSQL/Oracle data hosts while keeping the MySQL-only global sequence feature enabled; copying a dataHost config with a modified dbDriver value.","solutions":["Set the dataHost's dbDriver to the native mysql driver in the dataHost configuration, or","Use a different global sequence type (e.g. ZK-based IncrSequenceZKHandler or timestamp sequence) that is driver-agnostic.","Check schema.xml/dataHost config so the sequence's dataNode points to a MySQL host."],"exampleFix":"// before (schema.xml dataHost)\n<dbDriver>jdbc</dbDriver>\n// after\n<dbDriver>native</dbDriver>","handlingStrategy":"validation","validationCode":"if (!\"native\".equals(dataHostConfig.getDbDriver())) {\n    throw new IllegalArgumentException(\"global sequence type 1 requires native mysql dbDriver, got: \" + dataHostConfig.getDbDriver());\n}","typeGuard":"boolean supportsDbSequence(DataHostConfig c) { return \"native\".equals(c.getDbDriver()); }","tryCatchPattern":"try { seqVal.fetchSequenceFromDB(); } catch (RuntimeException e) { log.error(\"driver unsupported for sequences\", e); /* switch sequence type */ }","preventionTips":["Only use db-based global sequences with native MySQL data hosts","Review dataHost dbDriver in schema.xml before enabling sequences","Prefer ZK or timestamp sequences for non-MySQL backends"],"tags":["java","mysql","sequence","jdbc","unsupported"],"backgroundTag":"unsupported-operation","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"}