MyCATApache/Mycat-Server · error · RuntimeException

the select proess err ,the SelectResponse is empty

Error message

the select proess err ,the SelectResponse is empty

What it means

PostgreSQLBackendConnectionHandler.doProcessCommandComplete() handles a CommandComplete from the PG backend. When the command was a SELECT (isSelectComplete()==true) but the handler's SelectResponse accumulator is null — no RowDescription started a response object — it throws this RuntimeException instead of forwarding results.

Solutions

  1. Check the PG server log and MyCat log for a preceding ErrorResponse that broke the RowDescription->DataRow->CommandComplete sequence; fix the underlying query error first
  2. Upgrade/patch MyCat's PG handler to create a SelectResponse defensively when isSelectComplete() is true but response is null
  3. Close and recycle the affected backend connection — its protocol state is desynced
  4. Simplify/adjust the query that triggers the mislabeled packet flow (e.g. avoid the specific function/COPY path)

Example fix

// before
if (response == null) { throw new RuntimeException("the select proess err ,the SelectResponse is empty"); }
// after
if (response == null) { LOGGER.error("select complete without SelectResponse, con=" + con); con.close("select response missing"); return; }
Defensive patterns

Strategy: try-catch

Type guard

if (response == null) { /* skip/repair before processing */ }
// in handler code:
if (commandComplete.isSelectComplete() && response != null) { doProcessBusinessQuery(con, response, commandComplete); }

Try / catch

try { session.execute(select); } catch (RuntimeException e) { if (e.getMessage() != null && e.getMessage().contains("SelectResponse is empty")) { pool.invalidate(conn); /* retry on fresh connection */ } else { throw e; } }

Prevention

When it happens

Trigger: A CommandComplete for a SELECT arrives without a preceding RowDescription packet having created a SelectResponse, e.g. protocol desync, packets dropped/processed out of order, or a query the handler did not register as a select.

Common situations: Protocol desync after a prior PG error/ErrorResponse that skipped RowDescription; complex queries (e.g. via views/functions) whose packet flow the handler mislabels; MyCat PG backend bugs on extended-protocol or COPY-like flows.

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/67b43e2e1ee01675. Report an issue: GitHub.

Appendix: source

Thrown at src/main/java/io/mycat/backend/postgresql/PostgreSQLBackendConnectionHandler.java:289

		// end row
		bufferArray = MycatServer.getInstance().getBufferPool().allocateArray();
		eofPckg = new EOFPacket();
		eofPckg.packetId = ++packetId;
		eofPckg.write(bufferArray);
		eof = bufferArray.writeToByteArrayAndRecycle();
		if (con.getResponseHandler() != null) {
			con.getResponseHandler().rowEofResponse(eof, con);
		} else {
			LOGGER.error("响应句柄为空");
		}
	}

	private void doProcessCommandComplete(PostgreSQLBackendConnection con,
			CommandComplete commandComplete, SelectResponse response) {
		if (commandComplete.isSelectComplete()) {
			if (response == null) {
				throw new RuntimeException(
						"the select proess err ,the SelectResponse is empty");
			}
			doProcessBusinessQuery(con, response, commandComplete);
		} else {
			OkPacket okPck = new OkPacket();
			
			okPck.affectedRows =commandComplete.getAffectedRows();
			okPck.insertId =commandComplete.getInsertId();
			okPck.packetId = ++packetId;
			okPck.message = commandComplete.getCommandResponse().getBytes();
			con.getResponseHandler().okResponse(okPck.writeToBytes(), con);
		}
	}

	private void doProcessCopyInResponse(PostgreSQLBackendConnection con,
			CopyInResponse packet) {
		// TODO(复制数据暂时不需要)
	}

View on GitHub (pinned to 65f8d8beb7)