alibaba/canal · error · ServiceException

节点信息已存在

Error message

节点信息已存在

What it means

Thrown by NodeServerServiceImpl.save() when a NodeServer with the same ip AND adminPort already exists. The duplicate-check query counts matching rows and refuses the insert.

Source

Thrown at admin/admin-web/src/main/java/com/alibaba/otter/canal/admin/service/impl/NodeServerServiceImpl.java:44

import com.alibaba.otter.canal.protocol.SecurityUtil;

/**
 * 节点信息业务层
 *
 * @author rewerma 2019-07-13 下午05:12:16
 * @version 1.0.0
 */
@Service
public class NodeServerServiceImpl implements NodeServerService {

    public void save(NodeServer nodeServer) {
        int cnt = NodeServer.find.query()
            .where()
            .eq("ip", nodeServer.getIp())
            .eq("adminPort", nodeServer.getAdminPort())
            .findCount();
        if (cnt > 0) {
            throw new ServiceException("节点信息已存在");
        }

        nodeServer.save();

        if (nodeServer.getClusterId() == null) { // 单机模式
            CanalConfig canalConfig = new CanalConfig();
            canalConfig.setServerId(nodeServer.getId());
            String configTmp = TemplateConfigLoader.loadCanalConfig();
            canalConfig.setContent(configTmp);
            try {
                String contentMd5 = SecurityUtil.md5String(canalConfig.getContent());
                canalConfig.setContentMd5(contentMd5);
            } catch (NoSuchAlgorithmException e) {
            }
            canalConfig.save();
        }
    }

View on GitHub (pinned to 87be50e876)

Solutions

  1. Delete the existing NodeServer record (or update it) before re-adding.
  2. Use a distinct adminPort for the new server if it is genuinely a different node.
  3. Deduplicate on the client/UI to prevent double-submit.
  4. Query SELECT * FROM node_server WHERE ip=? AND admin_port=? to locate the conflicting record.
Defensive patterns

Strategy: validation

Validate before calling

int cnt = NodeServer.find.query().where().eq("ip", ip).eq("adminPort", adminPort).findCount();
if (cnt > 0) {
    throw new IllegalStateException("NodeServer " + ip + ":" + adminPort + " already exists");
}

Prevention

When it happens

Trigger: POST/register a NodeServer whose (ip, adminPort) pair already exists in node_server. The findCount() > 0 guard throws 'node info already exists'.

Common situations: Re-registering a server that was not deleted; double-submit in the UI; HA pair both registered with the same admin port by mistake; stale record after a server re-provision.

Related errors


AI-assisted analysis of alibaba/canal@87be50e876 (2026-08-14). Data as JSON: /api/errors/a744503034e16b51. Report an issue: GitHub.