MyCATApache/Mycat-Server · error · RuntimeException
unknown status!
Error message
unknown status!
What it means
MySQLConnectionHandler.handleData dispatches each backend packet based on the connection's resultStatus state machine (INIT, RESULT_STATUS_QUERY, PREPARE_RESPONSE_OK, ...). When the current status does not match any known case, the default branch throws RuntimeException("unknown status!") — an unhandled state in the packet-dispatch state machine.
Solutions
- Capture which resultStatus value triggered it (log it) and add a case for that state in handleData
- Upgrade MyCat — newer versions have extended handleData with additional RESULT_STATUS cases
- Close and rebuild the backend connection pool entry; the connection's state is inconsistent
- Check for concurrent use of one backend connection by two sessions (connection leak/race) and fix session-to-connection binding
Example fix
// before
default:
throw new RuntimeException("unknown status!");
// after
default:
LOGGER.error("unknown resultStatus: " + resultStatus);
source.close("unknown status: " + resultStatus);
break; Defensive patterns
Strategy: try-catch
Try / catch
try { stmt.execute(...); } catch (RuntimeException e) { if ("unknown status!".equals(e.getMessage())) { pool.invalidate(conn); /* rebuild backend connection */ } else { throw e; } } Prevention
- Never share one backend connection across concurrent sessions
- Close/reset connections cleanly on error paths
- Upgrade MyCat so handleData covers all RESULT_STATUS states
When it happens
Trigger: A backend packet arrives while resultStatus holds a value with no case in the switch (e.g. a status set elsewhere or corrupted/reset concurrently), such as a packet arriving after the status was changed to a value handleData does not know.
Common situations: Race conditions between connection close/reset and in-flight packets, state values introduced by newer code paths but not added to handleData, protocol desync after an error left the handler in an undefined status.
Understand the failure class
Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.
Related errors
- Unknown Packet!
- offer data error!
- invalid readbuffer capacity ,too little buffer size
- ER_UNKNOWN_COM_ERROR
- global seq and share join and special…
AI-assisted analysis of MyCATApache/Mycat-Server@65f8d8beb7 (2026-09-11).
Data as JSON: /api/errors/3e8f7de6a352258c.
Report an issue: GitHub.
Appendix: source
Thrown at src/main/java/io/mycat/backend/mysql/nio/MySQLConnectionHandler.java:155
case RESULT_STATUS_FIELD_EOF:
switch (data[4]) {
case ErrorPacket.FIELD_COUNT:
resultStatus = RESULT_STATUS_INIT;
handleErrorPacket(data);
break;
case EOFPacket.FIELD_COUNT:
resultStatus = RESULT_STATUS_INIT;
handleRowEofPacket(data);
break;
default:
handleRowPacket(data);
}
break;
case RESULT_STATUS_PREPARE_RESPONSE_OK:
handlePrepareOkPacket(data);
break;
default:
throw new RuntimeException("unknown status!");
}
}
public void setResponseHandler(ResponseHandler responseHandler) {
// logger.info("set response handler "+responseHandler);
// if (this.responseHandler != null && responseHandler != null) {
// throw new RuntimeException("reset agani!");
// }
// 连接释放后如果结果状态不正确则尝试设置一下
if( responseHandler==null && resultStatus!=RESULT_STATUS_INIT ) {
logger.warn("try to reset resultStatus. last responseHandler:{}, resultStatus = {}", this.responseHandler, resultStatus);
resultStatus = RESULT_STATUS_INIT;
}
this.responseHandler = responseHandler;
}
private void handleLogNodeInfo(String pkgName) {
Object att = source.getAttachment();View on GitHub (pinned to 65f8d8beb7)