MyCATApache/Mycat-Server · warning

ER_UNKNOWN_COM_ERROR

ER_UNKNOWN_COM_ERROR

Error message

Unsupported command

What it means

In ServerQueryHandler.query, the KILL_QUERY command code is deliberately unsupported (the comment notes MyCat does not support it). Instead of dispatching to a handler, the server logs 'Unsupported command:' with the SQL at WARN level and replies to the client with an ER_UNKNOWN_COM_ERROR packet carrying this message. It is a sentinel rejection of an unimplemented MySQL protocol command, not a parser or data failure — the connection stays open and other commands continue to be processed.

Solutions

  1. Use 'KILL <id>' (whole connection) instead of 'KILL QUERY <id>'.
  2. Kill the query at the backend MySQL directly rather than through MyCat.
  3. Replace pool kill-query behavior with statement/socket timeouts.

Example fix

// before
KILL QUERY 123;
// after
KILL 123;
Defensive patterns

Strategy: validation

Validate before calling

// Strip/redirect KILL QUERY before sending through MyCat
String normalized = sql.trim().toUpperCase();
if (normalized.startsWith("KILL QUERY")) {
    throw new UnsupportedOperationException("KILL QUERY unsupported by MyCat; use KILL or kill on backend MySQL");
}

Try / catch

try {
    stmt.execute(sql);
} catch (SQLException e) {
    if (e.getErrorCode() == 1047 /* ER_UNKNOWN_COM_ERROR */) {
        backendMySqlConnection(stmt -> stmt.execute(sql));
    }
}

Prevention

When it happens

Trigger: Client issues 'KILL QUERY <id>' or the MySQL protocol COM_QUERY form of killing a running query.

Common situations: JDBC/drivers or admin tools (mysql client, monitoring) that kill long-running queries; connection-pool validators issuing KILL QUERY on timeouts.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of MyCATApache/Mycat-Server@65f8d8beb7 (2026-09-11). Data as JSON: /api/errors/17b910d5e2b58298. Report an issue: GitHub.

Appendix: source

Thrown at src/main/java/io/mycat/server/ServerQueryHandler.java:112

		case ServerParse.SELECT:
			SelectHandler.handle(sql, c, rs >>> 8);
			break;
		case ServerParse.START:
			StartHandler.handle(sql, c, rs >>> 8);
			break;
		case ServerParse.BEGIN:
			BeginHandler.handle(sql, c);
			break;
		//不支持oracle的savepoint事务回退点
		case ServerParse.SAVEPOINT:
			SavepointHandler.handle(sql, c);
			break;
		case ServerParse.KILL:
			KillHandler.handle(sql, rs >>> 8, c);
			break;
		//不支持KILL_Query
		case ServerParse.KILL_QUERY:
			LOGGER.warn(new StringBuilder().append("Unsupported command:").append(sql).toString());
			c.writeErrMessage(ErrorCode.ER_UNKNOWN_COM_ERROR,"Unsupported command");
			break;
		case ServerParse.USE:
			UseHandler.handle(sql, c, rs >>> 8);
			break;
		case ServerParse.COMMIT:
			c.commit();
			break;
		case ServerParse.ROLLBACK:
			c.rollback();
			break;
		case ServerParse.HELP:
			LOGGER.warn(new StringBuilder().append("Unsupported command:").append(sql).toString());
			c.writeErrMessage(ErrorCode.ER_SYNTAX_ERROR, "Unsupported command");
			break;
		case ServerParse.MYSQL_CMD_COMMENT:
			c.write(c.writeToBuffer(OkPacket.OK, c.allocate()));
			break;

View on GitHub (pinned to 65f8d8beb7)