MyCATApache/Mycat-Server · error · RuntimeException
sequnce fetched failed from db
Error message
sequnce fetched failed from db
What it means
nextValue() increments and returns the cached current value, but only if a prior fetch of the sequence succeeded. If successFetched is false (fetch never ran or failed), it throws a RuntimeException instead of handing out a possibly invalid id.
Solutions
- Fix the underlying fetch failure (check Mycat logs for 'can't fetch sequnce in db' or the sequence-not-found error).
- Ensure the sequence exists in mycat_sequence and the backing MySQL is reachable.
- Retry the sequence request after the fetch succeeds rather than calling nextValue() on a failed SequenceVal.
Example fix
// before
long id = seqVal.nextValue(); // throws if fetch failed
// after
if (!seqVal.isSuccessFetched()) {
seqVal.fetchSequenceFromDB(); // or surface a clear error
}
long id = seqVal.nextValue(); Defensive patterns
Strategy: try-catch
Validate before calling
if (!seqVal.isSuccessFetched()) { throw new IllegalStateException("sequence not fetched yet, cannot produce ids"); } Type guard
boolean canProduceId(SequenceVal s) { return s.isSuccessFetched(); } Try / catch
try { long id = seqVal.nextValue(); } catch (RuntimeException e) { log.warn("sequence fetch failed, refetching", e); seqVal.fetchSequenceFromDB(); } Prevention
- Always check isSuccessFetched() before nextValue()
- Investigate fetch failures logged as 'can't fetch sequnce in db'
- Add health checks on the sequence backing DB
When it happens
Trigger: Calling nextValue() (via nexVal) when the asynchronous DB fetch failed, timed out, or the error from getSequenceByNaitve (e.g. missing sequence row) left successFetched=false.
Common situations: Sequence row missing in mycat_sequence (error 293), repeated DB connection failures during fetch, or application code reading ids after a fetch that already logged a failure.
Understand the failure class
Background: Database query failed: Internal Server Error 500s wrapping SQL, Prisma, and connection failures — what to check first — this error's family across 16 libraries.
Related errors
- fetching sequence can not support the db driver
- sequnce not found in db table
- Initial capacity exceeds maximum capacity of
- Page size cannot exceed
- error while calling spill() on
AI-assisted analysis of MyCATApache/Mycat-Server@65f8d8beb7 (2026-09-11).
Data as JSON: /api/errors/5844f7a96684e29a.
Report an issue: GitHub.
Appendix: source
Thrown at src/main/java/io/mycat/route/sequence/handler/SequenceVal.java:252
return physicalDatasource.getHostConfig();
}
public void sleep(long time) {
try {
Thread.sleep(time);
} catch (InterruptedException e) {
IncrSequenceMySQLHandler.LOGGER
.warn("wait db fetch sequnce err " + e);
}
}
//是否成功返回。
public boolean isSuccessFetched() {
return successFetched;
}
//下一个可用的id
public long nextValue() {
if (successFetched == false) {
throw new RuntimeException(
"sequnce fetched failed from db ");
}
return curVal.incrementAndGet();
}
}
View on GitHub (pinned to 65f8d8beb7)