apache/dolphinscheduler · error · IllegalStateException

Duplicate datasource processor named '%s'

Error message

Duplicate datasource processor named '%s'

What it means

Thrown by DataSourcePluginManager when ServiceLoader discovers two DataSourceProcessor implementations whose getDbType() returns the same database type name. Since processors are stored in a map keyed by DbType name, a duplicate would be ambiguous, so initialization fails fast. This is a plugin packaging / classpath conflict.

Source

Thrown at dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/main/java/org/apache/dolphinscheduler/plugin/datasource/api/plugin/DataSourcePluginManager.java:84

                (dataSourceChannelName, dataSourceChannelFactory) -> {
                    if (datasourceChannelMap.containsKey(dataSourceChannelName)) {
                        throw new IllegalStateException(
                                format("Duplicate datasource channel named '%s'", dataSourceChannelName));
                    }
                    datasourceChannelMap.put(dataSourceChannelName, dataSourceChannelFactory.create());
                    log.info("Registered datasource channel: {}", dataSourceChannelName);
                });
    }

    private static synchronized void initializeDataSourceProcessor() {
        if (MapUtils.isNotEmpty(dataSourceProcessorMap)) {
            return;
        }

        ServiceLoader.load(DataSourceProcessor.class).forEach(factory -> {
            final String name = factory.getDbType().getName();
            if (dataSourceProcessorMap.containsKey(name)) {
                throw new IllegalStateException(format("Duplicate datasource processor named '%s'", name));
            }
            DataSourceProcessor dataSourceProcessor = factory.create();
            dataSourceProcessorMap.put(name, dataSourceProcessor);
            log.info("Success register datasource processor -> {}", name);
        });
    }

}

View on GitHub (pinned to 02eac45a1b)

Solutions

  1. Identify jars containing META-INF/services/org.apache.dolphinscheduler.spi.datasource.DataSourceProcessor entries and find the duplicated DbType
  2. Remove duplicate/stale processor jars from the plugin/lib classpath
  3. In your custom processor, override getDbType() to return a distinct DbType, or do not extend a processor whose DbType is already registered
  4. Deduplicate META-INF/services files when building an uber-jar (shade ServicesResourceTransformer)

Example fix

// before
class MyPostgresProcessor extends PostgresDataSourceProcessor {
  // inherits getDbType() -> POSTGRES, duplicate registration
}
// after
@Override
public DbType getDbType() { return DbType.MY_POSTGRES; }
Defensive patterns

Strategy: try-catch

Validate before calling

Map<String,Integer> counts = new HashMap<>();
ServiceLoader.load(DataSourceProcessor.class).forEach(p -> counts.merge(p.getDbType().getName(), 1, Integer::sum));
counts.entrySet().stream().filter(e -> e.getValue() > 1).forEach(e -> System.out.println("duplicate: " + e));

Type guard

if (dataSourceProcessorMap.containsKey(name)) { log.warn("processor {} already registered, skipping", name); return; }

Try / catch

try {
  pluginManager.loadDataSourcePlugin();
} catch (IllegalStateException e) {
  if (e.getMessage().startsWith("Duplicate datasource processor")) {
    log.error("Duplicate DataSourceProcessor DbType: {}", e.getMessage());
  } else throw e;
}

Prevention

When it happens

Trigger: loadDataSourcePlugin -> initializeDataSourceProcessor encountering two jars that register a DataSourceProcessor for the same DbType via java.util.ServiceLoader, or the same processor class loaded twice.

Common situations: Custom datasource plugin extending an existing processor (e.g. subclassing MysqlDataSourceProcessor) without overriding getDbType(); duplicate plugin jars after upgrade; shaded uber-jar merging service descriptors.

Related errors


AI-assisted analysis of apache/dolphinscheduler@02eac45a1b (2026-09-06). Data as JSON: /api/errors/9be63e16cd4d16f1. Report an issue: GitHub.