{"record":{"id":"fbc129533e7d332d","repo":"MyCATApache/Mycat-Server","slug":"selfcheck-there-are-some-datasource-connection","errorCode":null,"errorMessage":"SelfCheck### there are some datasource connection failed, pls check!","messagePattern":"SelfCheck### there are some datasource connection failed, pls check!","errorType":"exception","errorClass":"io.mycat.config.ConfigException","httpStatus":null,"severity":"critical","filePath":"src/main/java/io/mycat/config/ConfigInitializer.java","lineNumber":214,"sourceCode":"\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\t//\n\t\t\tboolean isConnectivity = true;\n\t\t\tfor (Map.Entry<String, Boolean> entry : map.entrySet()) {\n\t\t\t\tString key = entry.getKey();\n\t\t\t\tBoolean value = entry.getValue();\n\t\t\t\tif ( !value && isConnectivity ) {\n\t\t\t\t\tLOGGER.warn(\"SelfCheck### test \" + key + \" database connection failed \");\t\t\t\t\t\t\t\n\t\t\t\t\tisConnectivity = false;\n\t\t\t\t\t\n\t\t\t\t} else {\n\t\t\t\t\tLOGGER.info(\"SelfCheck### test \" + key + \" database connection success \");\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tif ( !isConnectivity ) {\n\t\t\t\tthrow new ConfigException(\"SelfCheck### there are some datasource connection failed, pls check!\");\n\t\t\t}\n\t\t\t\t\n\t\t}\n\t\t\n\t}\n\n\tpublic SystemConfig getSystem() {\n\t\treturn system;\n\t}\n\n\tpublic MycatCluster getCluster() {\n\t\treturn cluster;\n\t}\n\n\tpublic FirewallConfig getFirewall() {\n\t\treturn firewall;\n\t}\n","sourceCodeStart":196,"sourceCodeEnd":232,"githubUrl":"https://github.com/MyCATApache/Mycat-Server/blob/65f8d8beb752f935752f2a0eec0ab017facab9ef/src/main/java/io/mycat/config/ConfigInitializer.java#L196-L232","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before (schema.xml)\n<dataHost name=\"host1\"><heartbeat>select user()</heartbeat>\n  <writeHost host=\"m1\" url=\"10.0.0.5:3306\" user=\"root\" password=\"old\"/>\n</dataHost>\n// after (corrected credentials)\n<dataHost name=\"host1\"><heartbeat>select user()</heartbeat>\n  <writeHost host=\"m1\" url=\"10.0.0.5:3306\" user=\"root\" password=\"newpass\"/>\n</dataHost>","handlingStrategy":"try-catch","validationCode":"// Probe each datasource before reload\nfor (String host : dataHosts.keySet()) {\n    try (Connection c = DriverManager.getConnection(jdbcUrl, user, pass)) {\n        // reachable\n    } catch (SQLException e) {\n        LOGGER.error(\"datasource {} unreachable: {}\", host, e.getMessage());\n    }\n}","typeGuard":null,"tryCatchPattern":"try {\n    reloadAll();\n} catch (ConfigException e) {\n    if (e.getMessage().contains(\"datasource connection failed\")) {\n        LOGGER.error(\"Backend connectivity check failed; keeping current config: {}\", e.getMessage());\n        // alert ops, keep old config active\n    } else { throw e; }\n}","preventionTips":["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."],"tags":["network","database","connectivity","mycat","reload"],"backgroundTag":"connection-refused","analyzedSha":"65f8d8beb752f935752f2a0eec0ab017facab9ef","analyzedAt":"2026-09-11T00:12:21.696Z","contentChangedAt":"2026-09-11T00:12:21.696Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}