alibaba/canal · critical · RuntimeException

No clickhouse adapter found for config key: {}

Error message

No clickhouse adapter found for config key: {}

What it means

Thrown by ClickHouseAdapter.init after loading all clickhouse mapping config files and filtering them through addConfig (which checks outerAdapterKey/destination match). If no config file matched this adapter's key, clickHouseMapping is empty and init aborts. This means the adapter was declared in the launcher config but no corresponding *-clickstore.yml mapping file was loaded or matched.

Source

Thrown at client-adapter/clickhouse/src/main/java/com/alibaba/otter/canal/client/adapter/clickhouse/ClickHouseAdapter.java:81

        return clickHouseMapping;
    }

    @Override
    public void init(OuterAdapterConfig configuration, Properties envProperties) {
        this.envProperties = envProperties;
        this.configuration = configuration;
        // Load DB type from adapter.launch/bootstrap.yml
        Map<String, String> properties = configuration.getProperties();
        String dbType = JdbcUtils.getDbType(properties.get("jdbc.url"), null);
        // 当.yml文件编码格式存在问题,此处clickhouse yml文件构建 可能会抛出异常
        Map<String, MappingConfig> clickHouseMappingTmp = ConfigLoader.load(envProperties);
        // 过滤不匹配的key的配置
        clickHouseMappingTmp.forEach((key, config) -> {
            addConfig(key, config);
        });

        if (clickHouseMapping.isEmpty()) {
            throw new RuntimeException("No clickhouse adapter found for config key: " + configuration.getKey());
        }

        // 初始化连接池
        dataSource = new DruidDataSource();
        dataSource.setDriverClassName(properties.get("jdbc.driverClassName"));
        dataSource.setUrl(properties.get("jdbc.url"));
        dataSource.setUsername(properties.get("jdbc.username"));
        dataSource.setPassword(properties.get("jdbc.password"));
        dataSource.setInitialSize(1);
        dataSource.setMinIdle(1);
        dataSource.setMaxActive(30);
        dataSource.setMaxWait(60000);
        dataSource.setTimeBetweenEvictionRunsMillis(60000);
        dataSource.setMinEvictableIdleTimeMillis(300000);
        dataSource.setUseUnfairLock(true);
        dataSource.setDefaultAutoCommit(false); // disable auto commit or disable Transactional
        dataSource.setDbType(dbType);

View on GitHub (pinned to 87be50e876)

Solutions

  1. Create at least one clickhouse mapping config file (e.g. mytable-clickhouse.yml) under the scanned resources/clickhouse directory.
  2. Ensure the mapping file's outerAdapterKey matches the adapter's key in the launcher config, or is null so prefix-matching applies.
  3. Confirm the mapping file name matches the loader's expected pattern (contains the marker 'clickhouse').
  4. Check that the yml parses (correct encoding UTF-8, valid YAML) so ConfigLoader does not silently skip it.

Example fix

# before: launcher declares adapter key 'clickhouse-1' but no mapping file matches
# after: create resources/clickhouse/mytable-clickhouse.yml with:
caseSensitive: true
outerAdapterKey: clickhouse-1
destination: exampleDb
dbMapping:
  database: mydb
  table: mytable
  targetTable: mytable
  targetPk:
    id: id
Defensive patterns

Strategy: validation

Validate before calling

// Before starting the adapter, assert at least one mapping file resolves to this key.
// (Run in a bootstrap check; clickHouseMapping is populated by addConfig matching outerAdapterKey.)
// Verify files exist and keys match:
// - launcher adapter key: e.g. 'clickhouse-1'
// - each mapping yml outerAdapterKey must equal 'clickhouse-1' (or be null for prefix match)

Try / catch

try {
    clickHouseAdapter.init(config, envProperties);
} catch (RuntimeException e) {
    if (e.getMessage().startsWith("No clickhouse adapter found")) {
        logger.error("No mapping config matched adapter key '{}'. Check outerAdapterKey in yml files.", config.getKey());
    }
    throw e;
}

Prevention

When it happens

Trigger: An adapter entry in the launcher YAML whose key has no matching mapping config file under resources/clickhouse/ (or the config dir); the mapping config's outerAdapterKey does not equal the adapter key and is not null-prefix-matched; the mapping file is missing or named so MappingConfigsLoader does not pick it up.

Common situations: Misnamed outerAdapterKey in the mapping file vs the adapter key in launcher config; mapping yml file placed outside the scanned path or with wrong suffix; yml encoding/format issue causing YamlUtils to return null; first-time setup forgetting to create the clickhouse mapping file.

Related errors


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