{"record":{"id":"3e8f7de6a352258c","repo":"MyCATApache/Mycat-Server","slug":"unknown-status","errorCode":null,"errorMessage":"unknown status!","messagePattern":"unknown status!","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/main/java/io/mycat/backend/mysql/nio/MySQLConnectionHandler.java","lineNumber":155,"sourceCode":"\t\t\tcase RESULT_STATUS_FIELD_EOF:\n\t\t\t\tswitch (data[4]) {\n\t\t\t\t\tcase ErrorPacket.FIELD_COUNT:\n\t\t\t\t\t\tresultStatus = RESULT_STATUS_INIT;\n\t\t\t\t\t\thandleErrorPacket(data);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase EOFPacket.FIELD_COUNT:\n\t\t\t\t\t\tresultStatus = RESULT_STATUS_INIT;\n\t\t\t\t\t\thandleRowEofPacket(data);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tdefault:\n\t\t\t\t\t\thandleRowPacket(data);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase RESULT_STATUS_PREPARE_RESPONSE_OK:\n                handlePrepareOkPacket(data);\n\t\t\t    break;\n\t\t\tdefault:\n\t\t\t\tthrow new RuntimeException(\"unknown status!\");\n\t\t}\n\t}\n\n\tpublic void setResponseHandler(ResponseHandler responseHandler) {\n\t\t// logger.info(\"set response handler \"+responseHandler);\n\t\t// if (this.responseHandler != null && responseHandler != null) {\n\t\t// throw new RuntimeException(\"reset agani!\");\n\t\t// }\n\t\t// 连接释放后如果结果状态不正确则尝试设置一下\n\t\tif( responseHandler==null && resultStatus!=RESULT_STATUS_INIT ) {\n\t\t\tlogger.warn(\"try to reset resultStatus. last responseHandler:{}, resultStatus = {}\", this.responseHandler, resultStatus);\n\t\t\tresultStatus = RESULT_STATUS_INIT;\n\t\t}\n\t\tthis.responseHandler = responseHandler;\n\t}\n\n\tprivate void handleLogNodeInfo(String pkgName) {\n\t\tObject att = source.getAttachment();","sourceCodeStart":137,"sourceCodeEnd":173,"githubUrl":"https://github.com/MyCATApache/Mycat-Server/blob/65f8d8beb752f935752f2a0eec0ab017facab9ef/src/main/java/io/mycat/backend/mysql/nio/MySQLConnectionHandler.java#L137-L173","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\ndefault:\n    throw new RuntimeException(\"unknown status!\");\n// after\ndefault:\n    LOGGER.error(\"unknown resultStatus: \" + resultStatus);\n    source.close(\"unknown status: \" + resultStatus);\n    break;","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { stmt.execute(...); } catch (RuntimeException e) { if (\"unknown status!\".equals(e.getMessage())) { pool.invalidate(conn); /* rebuild backend connection */ } else { throw e; } }","preventionTips":["Never share one backend connection across concurrent sessions","Close/reset connections cleanly on error paths","Upgrade MyCat so handleData covers all RESULT_STATUS states"],"tags":["state-machine","mysql","nio","protocol"],"backgroundTag":"invalid-state-transition","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"}