{"record":{"id":"34eda6e8efe2844b","repo":"MyCATApache/Mycat-Server","slug":"offer-data-error","errorCode":null,"errorMessage":"offer data error!","messagePattern":"offer data error!","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/main/java/io/mycat/backend/mysql/nio/MySQLConnectionHandler.java","lineNumber":91,"sourceCode":"\t\tif (responseHandler != null) {\n\t\t\tresponseHandler.connectionError(e, source);\n\t\t}\n\t\tLOGGER.error(\"connectionError but not handle\");\n\t}\n\n\tpublic MySQLConnection getSource() {\n\t\treturn source;\n\t}\n\n\t@Override\n\tpublic void handle(byte[] data) {\n\t\tofferData(data, source.getProcessor().getExecutor());\n\t}\n\n\t@Override\n\tprotected void offerDataError() {\n\t\tresultStatus = RESULT_STATUS_INIT;\n\t\tthrow new RuntimeException(\"offer data error!\");\n\t}\n\n\t@Override\n\tprotected void handleData(byte[] data) {\n\t\tswitch (resultStatus) {\n\t\t\tcase RESULT_STATUS_INIT:\n\t\t\t\tswitch (data[4]) {\n\t\t\t\t\tcase OkPacket.FIELD_COUNT:\n                        int packetSize = (int) ByteUtil.readLength(data, 0);\n                        // COM_STMT_PREPARE_OK状态标识 [00]，和OK包一致，区别是COM_STMT_PREPARE_OK固定长度为12\n                        if (packetSize == PreparedOkPacket.PACKET_SIZE\n                                && (responseHandler != null && responseHandler instanceof PrepareRequestHandler)) {\n                            handlePrepareOkPacket(data);\n                            resultStatus = RESULT_STATUS_PREPARE_RESPONSE_OK;\n                        } else {\n                            handleOkPacket(data);\n                        }\n\t\t\t\t\t\tbreak;","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/MyCATApache/Mycat-Server/blob/65f8d8beb752f935752f2a0eec0ab017facab9ef/src/main/java/io/mycat/backend/mysql/nio/MySQLConnectionHandler.java#L73-L109","documentation":"MySQLConnectionHandler (a NIO packet handler) queues incoming backend packets onto the connection's processor executor via offerData(). If the queue rejects the task (executor queue full/shutdown), offerDataError() is invoked, which resets resultStatus to RESULT_STATUS_INIT and throws RuntimeException(\"offer data error!\").","triggerScenarios":"The backend connection's processor executor queue is full or its executor has been shut down while binary/row packets arrive, so offerData(data, source.getProcessor().getExecutor()) cannot enqueue the packet.","commonSituations":"Heavy load with a saturated NIO processor queue (QueueSize limit hit), system overload or executor rejection policy discarding tasks, backend threads shutting down during MyCat shutdown while connections still stream data.","solutions":["Increase the processor's task queue size / NIO processor count in server.xml (processors, processorExecutorSize) to absorb bursts","Investigate and fix the slow consumer (responseHandler) that lets the queue fill — often a stuck frontend session or slow SQL","Add/keep rejection handling so the backend connection is closed cleanly instead of an uncaught RuntimeException propagating through the NIO thread","Retry the query; this is transient under load"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { session.execute(...); } catch (RuntimeException e) { if (\"offer data error!\".equals(e.getMessage())) { session.close(); /* retry on a new connection */ } else { throw e; } }","preventionTips":["Size processorExecutorSize/queue for peak load","Monitor executor queue depth and shed load before rejection","Avoid unbounded result streaming into saturated sessions"],"tags":["nio","executor","backpressure","mysql"],"backgroundTag":"internal-invariant-violation","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"}