MyCATApache/Mycat-Server · error · RuntimeException

fetching sequence can not support the db driver

Error message

fetching sequence can not support the db driver:{dbDriver}

What it means

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.

Solutions

  1. Set the dataHost's dbDriver to the native mysql driver in the dataHost configuration, or
  2. Use a different global sequence type (e.g. ZK-based IncrSequenceZKHandler or timestamp sequence) that is driver-agnostic.
  3. Check schema.xml/dataHost config so the sequence's dataNode points to a MySQL host.

Example fix

// before (schema.xml dataHost)
<dbDriver>jdbc</dbDriver>
// after
<dbDriver>native</dbDriver>
Defensive patterns

Strategy: validation

Validate before calling

if (!"native".equals(dataHostConfig.getDbDriver())) {
    throw new IllegalArgumentException("global sequence type 1 requires native mysql dbDriver, got: " + dataHostConfig.getDbDriver());
}

Type guard

boolean supportsDbSequence(DataHostConfig c) { return "native".equals(c.getDbDriver()); }

Try / catch

try { seqVal.fetchSequenceFromDB(); } catch (RuntimeException e) { log.error("driver unsupported for sequences", e); /* switch sequence type */ }

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of MyCATApache/Mycat-Server@65f8d8beb7 (2026-09-11). Data as JSON: /api/errors/f7a4b59461daf31c. Report an issue: GitHub.

Appendix: source

Thrown at src/main/java/io/mycat/route/sequence/handler/SequenceVal.java:86

	 *1.后端获取序列
	 *  如果返回的结果为超时,异常,尝试数据库重试获取
	 *     返回的为0,0   尝试数据库重试获取
	 *     结果还未返回,调用函数继续等待
	 *  成功返回则正常返回
	 * */

	public Long[] fetchSequenceFromDB(FetchMySQLSequnceHandler mysqlSeqFetcher, int retryCount, boolean canSendFetch) {
		DataHostConfig dataHostConfig = getDBHostConfig();

		if (dataHostConfig.isJDBCDriver()) {
			return getSequenceValueByJDBC(retryCount);
		}

		if (dataHostConfig.isNativeDriver()) {
			return getSequenceByNaitve(mysqlSeqFetcher, retryCount, canSendFetch);
		}

		throw new RuntimeException("fetching sequence can not support the db driver:" + dataHostConfig.getDbDriver());
	}

	private Long[] getSequenceByNaitve(FetchMySQLSequnceHandler mysqlSeqFetcher, int retryCount, boolean canSendFetch) {
		final int systemRetryCount = MycatServer.getInstance().getConfig().getSystem().getSequnceMySqlRetryCount();
		//进入waitFinish小于4次,或者可以后端获取数据
		if(retryCount <= systemRetryCount && canSendFetch) {

			this.reset();
			mysqlSeqFetcher.execute(this);
		} else if(retryCount > systemRetryCount){
			fetching.compareAndSet(true, false); //
			return null;
		}
		long start = System.currentTimeMillis();
		//直接等待
		long mysqlWaitTime = MycatServer.getInstance().getConfig().getSystem().getSequnceMySqlWaitTime();

		long end = start + mysqlWaitTime;

View on GitHub (pinned to 65f8d8beb7)