MyCATApache/Mycat-Server · error

ER_PARSE_ERROR

ER_PARSE_ERROR

Error message

can't find (root) parent sharding node for sql:" + origSQL

What it means

Thrown (as a write-error to the client with logged warning) when inserting into a child table whose parent row cannot be located: MyCat runs a FetchStoreNodeOfChildTableHandler query against the root/parent sharding tables to find which datanode holds the referenced parent key, and if the async callback returns an empty result the parent record does not exist, so the child insert has no valid route and the error 'can't find (root) parent sharding node' is raised with the original SQL. It fires for ER-relation inserts where referential integrity is violated — the parent row is missing or the sharding key value is wrong.

Solutions

  1. Insert the parent row first, then retry the child-table INSERT; the fetch of the root parent's datanode will then succeed
  2. Verify the parent key value in the SQL is correct and actually exists in the root parent table
  3. If the child table's sharding relationship is misconfigured (wrong root parent or join key), fix the schema's childTable configuration so the root parent lookup SQL targets the right table
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at src/main/java/io/mycat/route/util/RouterUtil.java:2002 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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

Appendix: source

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

							FetchStoreNodeOfChildTableHandler fetchHandler = new FetchStoreNodeOfChildTableHandler();
							return fetchHandler.execute(schema.getName(), findRootTBSql, tc.getRootParent().getDataNodes(), sc);
						}

					}
				});


				Futures.addCallback(listenableFuture, new FutureCallback<String>() {
					@Override
					public void onSuccess(String result) {
						//结果为空,证明上一级表中不存在那条记录,失败
						if (Strings.isNullOrEmpty(result)) {
							StringBuilder s = new StringBuilder();
							LOGGER.warn(s.append(sc.getSession2()).append(origSQL).toString() +
									" err:" + "can't find (root) parent sharding node for sql:" + origSQL);
							if(!sc.isAutocommit()) { // 处于事务下失败, 必须回滚
								sc.setTxInterrupt("can't find (root) parent sharding node for sql:" + origSQL);
							}
							sc.writeErrMessage(ErrorCode.ER_PARSE_ERROR, "can't find (root) parent sharding node for sql:" + origSQL);
							return;
						}

						if (LOGGER.isDebugEnabled()) {
							LOGGER.debug("found partion node for child table to insert " + result + " sql :" + origSQL);
						}
						//找到分片,进行插入(和其他的一样,需要判断是否需要全局自增ID)
						boolean processedInsert=false;
						if ( sc!=null && tc.isAutoIncrement()) {
							try {
								String primaryKey = tc.getPrimaryKey();
								processedInsert=processInsert(sc,schema,ServerParse.INSERT,origSQL,tc.getName(),primaryKey);
							} catch (SQLNonTransientException e) {
								LOGGER.warn("sequence processInsert error,",e);
								sc.writeErrMessage(ErrorCode.ER_PARSE_ERROR , "sequence processInsert error," + e.getMessage());
							}
						}

View on GitHub (pinned to 65f8d8beb7)