MyCATApache/Mycat-Server · error · ConfigException

dataNode ' ' is not found!

Error message

dataNode '${node}' is not found!

What it means

Thrown by XMLSchemaLoader.checkDataNodeExists when a table or child table references a dataNode name that was never defined as a <dataNode> element. Mycat validates every referenced node exists in the dataNodes map before schema loading completes.

Solutions

  1. Add the missing <dataNode name="..." dataHost="..." database="..."> definition to schema.xml
  2. Fix the dataNode attribute spelling on the offending <table> element
  3. List all defined dataNodes and cross-check every table reference

Example fix

// before (schema.xml)
<table name="t" dataNode="dn2" /> <!-- dn2 undefined -->
// after
<dataNode name="dn2" dataHost="localhost1" database="db2" />
<table name="t" dataNode="dn2" />
Defensive patterns

Strategy: validation

Validate before calling

// verify all dataNode references on tables exist before load
Set<String> defined = collectDataNodeNames("schema.xml");
for (Element t : schemaTables("schema.xml")) {
    for (String dn : t.getAttribute("dataNode").replaceAll("distribute\\(|\\)", "").split("[,$-]")) {
        if (!defined.contains(dn.trim()))
            throw new IllegalStateException("Unknown dataNode: " + dn);
    }
}

Try / catch

try {
    configLoader.load();
} catch (ConfigException e) {
    if (e.getMessage().contains("dataNode") && e.getMessage().contains("is not found")) {
        String node = extractQuoted(e.getMessage());
        log.error("Define <dataNode name='" + node + "'> or fix the table reference", e);
    }
    throw e;
}

Prevention

When it happens

Trigger: A <table name="t" dataNode="dn9"> where dn9 is not defined by any <dataNode name="dn9">; also invoked for distributed dataNode lists expanded from distribute() syntax or child-table dataNodes.

Common situations: Typo in a table's dataNode attribute; dataNode removed from schema.xml but tables still reference it; range-expanded names like dn1$0-75 not covering the referenced index.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of MyCATApache/Mycat-Server@65f8d8beb7 (2026-09-11). Data as JSON: /api/errors/4bfd42f5f9e983c2. Report an issue: GitHub.

Appendix: source

Thrown at src/main/java/io/mycat/config/loader/xml/XMLSchemaLoader.java:564

                    getDbType(dataNodes), null, false, parentTable, true,
                    joinKey, parentKey, subTables, false);

            if (tables.containsKey(table.getName())) {
                throw new ConfigException("table " + table.getName() + " duplicated!");
            }
            tables.put(table.getName(), table);
            //对于子表的子表,递归处理
            processChildTables(tables, table, dataNodes, childTbElement);
        }
    }

    private void checkDataNodeExists(Collection<String> nodes) {
        if (nodes == null || nodes.size() < 1) {
            return;
        }
        for (String node : nodes) {
            if (!dataNodes.containsKey(node)) {
                throw new ConfigException("dataNode '" + node + "' is not found!");
            }
        }
    }

    /**
     * 检查分片表分片规则配置, 目前主要检查分片表分片算法定义与分片dataNode是否匹配<br>
     * 例如分片表定义如下:<br>
     * {@code
     * <table name="hotnews" primaryKey="ID" autoIncrement="true" dataNode="dn1,dn2"
     * rule="mod-long" />
     * }
     * <br>
     * 分片算法如下:<br>
     * {@code
     * <function name="mod-long" class="io.mycat.route.function.PartitionByMod">
     * <!-- how many data nodes -->
     * <property name="count">3</property>
     * </function>

View on GitHub (pinned to 65f8d8beb7)