{"record":{"id":"7e866dc7c2290d23","repo":"alibaba/canal","slug":"not-allow-to-change-outadapterkey-7e866d","errorCode":null,"errorMessage":"not allow to change outAdapterKey","messagePattern":"not allow to change outAdapterKey","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"client-adapter/rdb/src/main/java/com/alibaba/otter/canal/client/adapter/rdb/RdbAdapter.java","lineNumber":316,"sourceCode":"        }\n    }\n\n    public boolean addConfig(String fileName, MappingConfig config) {\n        if (match(config)) {\n            rdbMapping.put(fileName, config);\n            addSyncConfigToCache(fileName, config);\n            FileName2KeyMapping.register(getClass().getAnnotation(SPI.class).value(), fileName,\n                    configuration.getKey());\n            return true;\n        }\n        return false;\n    }\n\n    public void updateConfig(String fileName, MappingConfig config) {\n        if (config.getOuterAdapterKey() != null && !config.getOuterAdapterKey()\n                .equals(configuration.getKey())) {\n            // 理论上不允许改这个 因为本身就是通过这个关联起Adapter和Config的\n            throw new RuntimeException(\"not allow to change outAdapterKey\");\n        }\n        rdbMapping.put(fileName, config);\n        addSyncConfigToCache(fileName, config);\n    }\n\n    public void deleteConfig(String fileName) {\n        rdbMapping.remove(fileName);\n        for (Map<String, MappingConfig> configMap : mappingConfigCache.values()) {\n            if (configMap != null) {\n                configMap.remove(fileName);\n            }\n        }\n        FileName2KeyMapping.unregister(getClass().getAnnotation(SPI.class).value(), fileName);\n    }\n\n    private boolean match(MappingConfig config) {\n        boolean sameMatch = config.getOuterAdapterKey() != null && config.getOuterAdapterKey()\n                .equalsIgnoreCase(configuration.getKey());","sourceCodeStart":298,"sourceCodeEnd":334,"githubUrl":"https://github.com/alibaba/canal/blob/87be50e87686a3e8af08c368d0e1ffd1f59eb04a/client-adapter/rdb/src/main/java/com/alibaba/otter/canal/client/adapter/rdb/RdbAdapter.java#L298-L334","documentation":"Thrown by RdbAdapter.updateConfig() when a hot-reloaded rdb mapping yml has an outerAdapterKey that differs from the key this adapter was initialized with. outerAdapterKey binds a Config to its Adapter and cannot be changed on a running adapter.","triggerScenarios":"A runtime config monitor reloads an rdb yml whose outerAdapterKey is non-null and not equal to configuration.getKey(), then calls updateConfig().","commonSituations":"Editing the 'outerAdapterKey:' line of an rdb mapping file while the adapter runs, or copying a file between adapter dirs that the monitor reloads.","solutions":["Revert the 'outerAdapterKey:' edit so it matches the adapter's key.","To legitimately change the key, stop the launcher, update both application.yml and the yml, and restart."],"exampleFix":"# before (adapter bound to key 'mysql1')\nouterAdapterKey: mysql2\n# after\nouterAdapterKey: mysql1","handlingStrategy":"validation","validationCode":"if (config.getOuterAdapterKey() != null\n        && !config.getOuterAdapterKey().equals(configuration.getKey())) {\n    logger.warn(\"Skip reload of {}: outerAdapterKey immutable at runtime\", fileName);\n    return;\n}","typeGuard":null,"tryCatchPattern":"try {\n    adapter.updateConfig(fileName, newConfig);\n} catch (RuntimeException e) {\n    if (e.getMessage().contains(\"not allow to change outAdapterKey\")) {\n        logger.warn(\"Skipped hot reload of {}: restart to rebind key\", fileName);\n    } else throw e;\n}","preventionTips":["Treat outerAdapterKey as immutable at runtime.","Re-key only via a full restart, updating application.yml and the yml together."],"tags":["rdb","config-update","hot-reload","canal"],"backgroundTag":null,"analyzedSha":"87be50e87686a3e8af08c368d0e1ffd1f59eb04a","analyzedAt":"2026-08-14T04:30:11.918Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}