MyCATApache/Mycat-Server · critical · io.mycat.config.ConfigException
SelfCheck### there are some datasource connection failed…
Error message
SelfCheck### there are some datasource connection failed, pls check!
What it means
Thrown by ConfigInitializer.testConnection when at least one configured dataHost datasource failed its connectivity test during a full config reload (reload_all). The initializer probes each datasource connection and aggregates results; if any isConnectivity flag stays false it throws this ConfigException so the reload aborts with a broken backend rather than serving traffic through a dead datasource.
Solutions
- Check the MyCat log for the preceding 'test <name> database connection' failure lines to identify which datasource failed.
- Verify the failing backend MySQL is running: connect directly with mysql client using the dataHost user/password/host/port from schema.xml.
- Fix the root cause (start MySQL, correct host/port/credentials, open firewall/network path).
- Retry the reload (reload @@config_all) and confirm the self-check passes.
- Remove or correct the datasource definition if that backend is permanently decommissioned.
Example fix
// before (schema.xml) <dataHost name="host1"><heartbeat>select user()</heartbeat> <writeHost host="m1" url="10.0.0.5:3306" user="root" password="old"/> </dataHost> // after (corrected credentials) <dataHost name="host1"><heartbeat>select user()</heartbeat> <writeHost host="m1" url="10.0.0.5:3306" user="root" password="newpass"/> </dataHost>
Defensive patterns
Strategy: try-catch
Validate before calling
// Probe each datasource before reload
for (String host : dataHosts.keySet()) {
try (Connection c = DriverManager.getConnection(jdbcUrl, user, pass)) {
// reachable
} catch (SQLException e) {
LOGGER.error("datasource {} unreachable: {}", host, e.getMessage());
}
} Try / catch
try {
reloadAll();
} catch (ConfigException e) {
if (e.getMessage().contains("datasource connection failed")) {
LOGGER.error("Backend connectivity check failed; keeping current config: {}", e.getMessage());
// alert ops, keep old config active
} else { throw e; }
} Prevention
- Monitor backend MySQL health (heartbeat/replication dashboards) before config reloads.
- Keep dataHost credentials in sync when rotating passwords.
- Test backend reachability from the MyCat host (network/firewall) after infra changes.
- Use reload @@config_all only when all backends are up; prefer staged reloads otherwise.
When it happens
Trigger: Calling the reload (reload_all, e.g. via manager 'reload @@config_all') while one or more MySQL backends defined in schema.xml <dataHost> entries are unreachable — host down, wrong port, bad credentials, firewall, or MySQL not accepting connections.
Common situations: A backend MySQL instance stopped or crashed; failover environment where a standby host is offline; wrong IP/port/password after infrastructure changes; network/firewall or DNS changes blocking MyCat-to-MySQL traffic; check SQL/schema property misconfiguration.
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
- CachePoolFactory not defined for type
- can't find cache pool
- SelfCheck### user all node is empty!
- SelfCheck### users node within the item is empty!
- SelfCheck### user refered schemas is empty!
AI-assisted analysis of MyCATApache/Mycat-Server@65f8d8beb7 (2026-09-11).
Data as JSON: /api/errors/fbc129533e7d332d.
Report an issue: GitHub.
Appendix: source
Thrown at src/main/java/io/mycat/config/ConfigInitializer.java:214
}
}
//
boolean isConnectivity = true;
for (Map.Entry<String, Boolean> entry : map.entrySet()) {
String key = entry.getKey();
Boolean value = entry.getValue();
if ( !value && isConnectivity ) {
LOGGER.warn("SelfCheck### test " + key + " database connection failed ");
isConnectivity = false;
} else {
LOGGER.info("SelfCheck### test " + key + " database connection success ");
}
}
if ( !isConnectivity ) {
throw new ConfigException("SelfCheck### there are some datasource connection failed, pls check!");
}
}
}
public SystemConfig getSystem() {
return system;
}
public MycatCluster getCluster() {
return cluster;
}
public FirewallConfig getFirewall() {
return firewall;
}
View on GitHub (pinned to 65f8d8beb7)