{"record":{"id":"a999532002aa0adb","repo":"MyCATApache/Mycat-Server","slug":"can-t-suport-district-table-tablename-schema-a99953","errorCode":null,"errorMessage":"can't suport district table  + tableName +  schema: + schema.getName() +  for mutiple dataNode  + dataNodes","messagePattern":"can't suport district table  \\+ tableName \\+  schema: \\+ schema\\.getName\\(\\) \\+  for mutiple dataNode  \\+ dataNodes","errorType":"exception","errorClass":"SQLNonTransientException","httpStatus":null,"severity":"error","filePath":"src/main/java/io/mycat/route/util/RouterUtil.java","lineNumber":1453,"sourceCode":"            String msg = \"can't find table define in schema \" + tableName + \" schema:\" + schema.getName();\r\n            LOGGER.warn(msg);\r\n            throw new SQLNonTransientException(msg);\r\n        }\r\n        if(tableConfig.isGlobalTable()){\r\n            String msg = \"can't suport district table  \" + tableName + \" schema:\" + schema.getName() + \" for global table \";\r\n            LOGGER.warn(msg);\r\n            throw new SQLNonTransientException(msg);\r\n        }\r\n        String partionCol = tableConfig.getPartitionColumn();\r\n    //  String primaryKey = tableConfig.getPrimaryKey();\r\n        //boolean isLoadData=false;\r\n    \r\n        Set<String> tablesRouteSet = new HashSet<String>();\r\n    \r\n        List<String> dataNodes = tableConfig.getDataNodes();\r\n        if(dataNodes.size()>1){\r\n            String msg = \"can't suport district table  \" + tableName + \" schema:\" + schema.getName() + \" for mutiple dataNode \" + dataNodes;\r\n            LOGGER.warn(msg);\r\n            throw new SQLNonTransientException(msg);\r\n        }\r\n        String dataNode = dataNodes.get(0);\r\n    \r\n        RouteResultsetNode[] nodes = null;\r\n        //主键查找缓存暂时不实现\r\n        if(tablesAndConditions.isEmpty()){\r\n            List<String> subTables = tableConfig.getDistTables();\r\n            tablesRouteSet.addAll(subTables);\r\n    \r\n            nodes = getNode(rrs, orgSql, tablesRouteSet, dataNode, false, tableName);\r\n        } else {\r\n            if (entry == null) {\r\n                for(Map.Entry<String, Map<String, Set<ColumnRoutePair>>> entry1 : tablesAndConditions.entrySet()) {\r\n                    //boolean isFoundPartitionValue = partionCol != null && entry.getValue().get(partionCol) != null;\r\n                    setNodes(rrs, tableConfig, partionCol, tablesRouteSet, entry1);\r\n                }\r\n            } else {\r","sourceCodeStart":1435,"sourceCodeEnd":1471,"githubUrl":"https://github.com/MyCATApache/Mycat-Server/blob/65f8d8beb752f935752f2a0eec0ab017facab9ef/src/main/java/io/mycat/route/util/RouterUtil.java#L1435-L1471","documentation":"A district (dist) table must map to exactly one data node in this routing path; RouterUtil reads tableConfig.getDataNodes() and throws SQLNonTransientException when more than one dataNode is configured, since it picks dataNodes.get(0) and cannot distribute.","triggerScenarios":"Routing a dist table whose <table> declaration in schema.xml lists multiple dataNodes (dataNodes.size()>1), e.g. dataNode=\"dn1,dn2\".","commonSituations":"Copy-pasted sharded table config applied to a dist table; schema.xml edited to scale out nodes without realizing dist-table routing requires a single node per dist table; mixing sharded-table and dist-table semantics.","solutions":["Configure exactly one dataNode for the dist table in schema.xml (dataNode=\"dn1\") and reload","Use multiple dist tables (orders$0, orders$1) each on its own dataNode instead of one table on many nodes","Route as a normal sharded table (with rule/partition column) if multi-node distribution is actually needed"],"exampleFix":"// before (schema.xml)\n<table name=\"orders\" distTables=\"orders$0\" dataNode=\"dn1,dn2\"/>\n// after\n<table name=\"orders\" distTables=\"orders$0\" dataNode=\"dn1\"/>","handlingStrategy":"validation","validationCode":"// validate config: dist tables must map to exactly one dataNode\n// parse schema.xml before deploy\nfor (TableDef t : distTables) {\n    if (t.dataNodes.size() != 1)\n        throw new IllegalStateException(\"Dist table \" + t.name + \" must have exactly one dataNode, got \" + t.dataNodes);\n}","typeGuard":null,"tryCatchPattern":"try {\n    execute(sql);\n} catch (SQLNonTransientException e) {\n    if (e.getMessage().contains(\"for mutiple dataNode\"))\n        throw new IllegalStateException(\"Fix schema.xml: dist table needs a single dataNode\", e);\n    throw e;\n}","preventionTips":["Add a config lint step asserting dist tables have one dataNode each","Split large dist tables into per-node sub-tables instead of multi-node declarations"],"tags":["sql","routing","dist-table","config"],"backgroundTag":"conflicting-config-options","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"}