MyCATApache/Mycat-Server · error · java.sql.SQLNonTransientException

can't suport district table

Error message

can't suport district table  ${tableName} schema:${schema.getName()} for global table 

What it means

Thrown when the table being routed as a district (dist) table is actually configured as a global table. Global tables have their own replication routing and cannot be routed with the dist-table mechanism.

Solutions

  1. Remove type="global" from the table definition in schema.xml if it should be a dist table, or stop using dist-table routing for it
  2. Keep global tables out of dist-table routing paths (configure them as normal global tables with dataNodes only)
  3. Reload Mycat config after fixing schema.xml

Example fix

// before (schema.xml)
<table name="dict" type="global" dataNode="dn1,dn2"/>
// after (as dist table)
<table name="dict" dataNode="dn1" distTables="dict_$0-9"/>
Defensive patterns

Strategy: validation

Validate before calling

TableConfig tc = schema.getTables().get(tableName.toUpperCase());
if (tc != null && tc.isGlobalTable()) throw new IllegalArgumentException("global table cannot use dist routing: " + tableName);

Type guard

if (tc != null && tc.isGlobalTable()) { /* skip dist-table path */ }

Try / catch

try { rrs = route(...); } catch (SQLNonTransientException e) { if (e.getMessage().contains("global table")) { LOG.warn("remove type=global or use dist routing, not both"); } throw e; }

Prevention

When it happens

Trigger: routeToDistTableNode is invoked for a table whose TableConfig.isGlobalTable() returns true — i.e. schema.xml marks it with type="global" while dist-table routing is attempted.

Common situations: schema.xml misconfiguration where a table has both global type semantics and dist table usage; developer refactoring a global table into dist tables without removing type="global"; SQL path that unexpectedly reaches dist routing for global tables.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


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

Appendix: source

Thrown at src/main/java/io/mycat/route/util/RouterUtil.java:1442


        String tableName = null;
        if (entry != null) {
            tableName = entry.getKey().toUpperCase();
        } else {
            List<String> tables = rrs.getTables();
            tableName = tables.get(0);
        }
        TableConfig tableConfig = schema.getTables().get(tableName);
        if(tableConfig == null) {
            String msg = "can't find table define in schema " + tableName + " schema:" + schema.getName();
            LOGGER.warn(msg);
            throw new SQLNonTransientException(msg);
        }
        if(tableConfig.isGlobalTable()){
            String msg = "can't suport district table  " + tableName + " schema:" + schema.getName() + " for global table ";
            LOGGER.warn(msg);
            throw new SQLNonTransientException(msg);
        }
        String partionCol = tableConfig.getPartitionColumn();
    //  String primaryKey = tableConfig.getPrimaryKey();
        //boolean isLoadData=false;
    
        Set<String> tablesRouteSet = new HashSet<String>();
    
        List<String> dataNodes = tableConfig.getDataNodes();
        if(dataNodes.size()>1){
            String msg = "can't suport district table  " + tableName + " schema:" + schema.getName() + " for mutiple dataNode " + dataNodes;
            LOGGER.warn(msg);
            throw new SQLNonTransientException(msg);
        }
        String dataNode = dataNodes.get(0);
    
        RouteResultsetNode[] nodes = null;
        //主键查找缓存暂时不实现
        if(tablesAndConditions.isEmpty()){

View on GitHub (pinned to 65f8d8beb7)