MyCATApache/Mycat-Server · error · RuntimeException
errr
Error message
errr
What it means
In the close(reason) path, AbstractConnection detects that the close reason string itself contains 'connection,reason:java.net.ConnectException' — i.e. a nested/recursive close with a ConnectException reason — and throws RuntimeException(" errr") as a debug guard. It indicates the connection is being closed because a backend connect failed.
Solutions
- Fix backend connectivity: verify dataHost url host/port, that MySQL is running, and reachable (telnet/nc the port).
- Correct schema.xml dataNode/dataHost configuration and reload config.
- Check firewalls/security groups between mycat and the MySQL nodes.
- If this is a cascaded close (double close), fix the caller that closes twice; upgrade mycat where double-close cleanup was fixed (e.g. issue#1616 style fixes).
Example fix
// before (schema.xml) <writeHost host="hostM1" url="10.0.0.3:3307" .../> // after <writeHost host="hostM1" url="10.0.0.3:3306" .../>
Defensive patterns
Strategy: retry
Validate before calling
// probe backend before routing requests
try (Socket s = new Socket()) {
s.connect(new InetSocketAddress(host, port), 3000); // must succeed
} Try / catch
try {
conn.close(reason);
} catch (RuntimeException e) {
if (" errr".equals(e.getMessage())) {
LOGGER.error("backend connect failed; verify dataHost {}:{}", host, port);
}
} Prevention
- Health-check MySQL backends and keep schema.xml hosts/ports correct
- Alert on mycat connect logs (java.net.ConnectException)
- Avoid double-closing connections; centralize close logic
When it happens
Trigger: close(String reason) is invoked with a reason produced by a previous failed close containing 'java.net.ConnectException', typically when mycat cannot establish a TCP connection to a backend MySQL node.
Common situations: Backend MySQL down or wrong host/port in schema.xml/dataHost config; firewall blocking the port; DNS failure; backend pool exhausted and connect refused during failover.
Understand the failure class
Background: ECONNREFUSED and "connection refused" / "could not connect to server" errors: what they mean and how to fix them — this error's family across 44 libraries.
Related errors
- failed to connect to zookeeper service
- Unexpected exception
- err.errno
- Unknown Packet!
- SelfCheck### there are some datasource connection failed…
AI-assisted analysis of MyCATApache/Mycat-Server@65f8d8beb7 (2026-09-11).
Data as JSON: /api/errors/06b0f665e08c40aa.
Report an issue: GitHub.
Appendix: source
Thrown at src/main/java/io/mycat/net/AbstractConnection.java:533
@Override
public void close(String reason) {
if (!isClosed.get()) {
closeSocket();
isClosed.set(true);
if (processor != null) {
processor.removeConnection(this);
}
this.cleanup();
isSupportCompress = false;
// ignore null information
if (Strings.isNullOrEmpty(reason)) {
return;
}
LOGGER.info("close connection,reason:" + reason + " ," + this);
if (reason.contains("connection,reason:java.net.ConnectException")) {
throw new RuntimeException(" errr");
}
} else {
// make sure cleanup again
// Fix issue#1616
this.cleanup();
}
}
public boolean isClosed() {
return isClosed.get();
}
public void idleCheck() {
if (isIdleTimeout()) {
LOGGER.info(toString() + " idle timeout");
close(" idle ");
}
}View on GitHub (pinned to 65f8d8beb7)