{"record":{"id":"d7c8aacb21a25970","repo":"MyCATApache/Mycat-Server","slug":"datahost-dbnode-getdbpool-gethostname-do-no","errorCode":null,"errorMessage":"dataHost:${dbNode.getDbPool().getHostName()} do not config the salveIDs field","messagePattern":"dataHost:(.+?) do not config the salveIDs field","errorType":"exception","errorClass":"java.lang.RuntimeException","httpStatus":null,"severity":"error","filePath":"src/main/java/io/mycat/server/handler/MigrateHandler.java","lineNumber":369,"sourceCode":"        Map<String, List<MigrateTask>> taskMap = new HashMap<>();\n        for (MigrateTask migrateTask : migrateTaskList) {\n            String dataHost = getDataHostNameFromNode(migrateTask.getFrom());\n            if (taskMap.containsKey(dataHost)) {\n                taskMap.get(dataHost).add(migrateTask);\n            } else {\n                taskMap.put(dataHost, Lists.newArrayList(migrateTask));\n            }\n        }\n\n\n        return taskMap;\n    }\n\n    private static int getSlaveIdFromZKForDataNode(String dataNode) {\n        PhysicalDBNode dbNode = MycatServer.getInstance().getConfig().getDataNodes().get(dataNode);\n        String slaveIDs = dbNode.getDbPool().getSlaveIDs();\n        if (Strings.isNullOrEmpty(slaveIDs))\n            throw new RuntimeException(\"dataHost:\" + dbNode.getDbPool().getHostName() + \" do not config the salveIDs field\");\n\n        List<Integer> allSlaveIDList = parseSlaveIDs(slaveIDs);\n\n        String taskPath = ZKUtils.getZKBasePath() + \"slaveIDs/\" + dbNode.getDbPool().getHostName();\n        try {\n            slaveIDsLock.acquire(30, TimeUnit.SECONDS);\n            Set<Integer> zkSlaveIdsSet = new HashSet<>();\n            if (ZKUtils.getConnection().checkExists().forPath(taskPath) != null) {\n                List<String> zkHasSlaveIDs = ZKUtils.getConnection().getChildren().forPath(taskPath);\n                for (String zkHasSlaveID : zkHasSlaveIDs) {\n                    zkSlaveIdsSet.add(Integer.parseInt(zkHasSlaveID));\n                }\n            }\n            for (Integer integer : allSlaveIDList) {\n                if (!zkSlaveIdsSet.contains(integer)) {\n                    ZKUtils.getConnection().create().creatingParentsIfNeeded().forPath(taskPath + \"/\" + integer);\n                    return integer;\n                }","sourceCodeStart":351,"sourceCodeEnd":387,"githubUrl":"https://github.com/MyCATApache/Mycat-Server/blob/65f8d8beb752f935752f2a0eec0ab017facab9ef/src/main/java/io/mycat/server/handler/MigrateHandler.java#L351-L387","documentation":"Before migrating data, MigrateHandler must get a slave ID for the dataHost (to restrict migration reads to a replica). getSlaveIdFromZKForDataNode reads dbPool.getSlaveIDs(); when that field is null/empty (Strings.isNullOrEmpty) it throws RuntimeException that the dataHost has no salveIDs configured.","triggerScenarios":"Running a migrate/schedule command where the target dataNode's PhysicalDBPool was created without the slaveIDs property set (hostM not listing slaveIDs in schema.xml/server.xml or ZooKeeper config).","commonSituations":"Environments without read replicas where slaveIDs was never configured; partial migration from schema.xml to ZooKeeper so the field is lost; typo'd property name; single-node dev setups trying production migration tooling.","solutions":["Add a slaveIDs entry for the dataHost in schema.xml (e.g. <dataHost ...><readHost .../></dataHost> or slaveIDs=\"2\") and reload","If migrating via ZooKeeper mode, update the ZK dataHost config to include slaveIDs and sync to Mycat","Configure at least one read host/replica whose serverId can be used as the migration slave","If no replica exists, use a migration method that does not require slave-based throttling"],"exampleFix":"// before (schema.xml)\n<dataHost name=\"host1\" ...><writeHost host=\"m1\" url=\"...\"/></dataHost>\n// after\n<dataHost name=\"host1\" ...>\n  <writeHost host=\"m1\" url=\"...\">\n    <readHost host=\"s1\" url=\"...\" weight=\"0\"/>\n  </writeHost>\n</dataHost> <!-- gives slaveIDs -->","handlingStrategy":"validation","validationCode":"// Before running migrate, verify every involved dataHost has slaveIDs configured\nfor (String dn : dataNodes) {\n    String slaveIDs = config.getDataNodes().get(dn).getDbPool().getSlaveIDs();\n    if (slaveIDs == null || slaveIDs.isEmpty()) throw new IllegalStateException(dn + \"'s dataHost lacks slaveIDs\");\n}","typeGuard":null,"tryCatchPattern":"catch (RuntimeException e) { if (e.getMessage().contains(\"do not config the salveIDs field\")) { /* add readHost/slaveIDs to schema.xml and reload */ } throw e; }","preventionTips":["Define read hosts (slaveIDs) for every dataHost used in migrations","If config lives in ZooKeeper, verify ZK and schema.xml stay in sync","Dry-run migration prerequisites before scheduling real tasks"],"tags":["migration","config","zookeeper","slave","datanode"],"backgroundTag":"missing-required-config-field","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"}