MyCATApache/Mycat-Server · error · RuntimeException
offer data error!
Error message
offer data error!
What it means
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!").
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
Defensive patterns
Strategy: try-catch
Try / catch
try { session.execute(...); } catch (RuntimeException e) { if ("offer data error!".equals(e.getMessage())) { session.close(); /* retry on a new connection */ } else { throw e; } } Prevention
- Size processorExecutorSize/queue for peak load
- Monitor executor queue depth and shed load before rejection
- Avoid unbounded result streaming into saturated sessions
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
AI-assisted analysis of MyCATApache/Mycat-Server@65f8d8beb7 (2026-09-11).
Data as JSON: /api/errors/34eda6e8efe2844b.
Report an issue: GitHub.
Appendix: source
Thrown at src/main/java/io/mycat/backend/mysql/nio/MySQLConnectionHandler.java:91
if (responseHandler != null) {
responseHandler.connectionError(e, source);
}
LOGGER.error("connectionError but not handle");
}
public MySQLConnection getSource() {
return source;
}
@Override
public void handle(byte[] data) {
offerData(data, source.getProcessor().getExecutor());
}
@Override
protected void offerDataError() {
resultStatus = RESULT_STATUS_INIT;
throw new RuntimeException("offer data error!");
}
@Override
protected void handleData(byte[] data) {
switch (resultStatus) {
case RESULT_STATUS_INIT:
switch (data[4]) {
case OkPacket.FIELD_COUNT:
int packetSize = (int) ByteUtil.readLength(data, 0);
// COM_STMT_PREPARE_OK状态标识 [00],和OK包一致,区别是COM_STMT_PREPARE_OK固定长度为12
if (packetSize == PreparedOkPacket.PACKET_SIZE
&& (responseHandler != null && responseHandler instanceof PrepareRequestHandler)) {
handlePrepareOkPacket(data);
resultStatus = RESULT_STATUS_PREPARE_RESPONSE_OK;
} else {
handleOkPacket(data);
}
break;View on GitHub (pinned to 65f8d8beb7)