apache/druid · error · IllegalArgumentException

Datasource metadata instance does not match required, found…

Error message

Datasource metadata instance does not match required, found instance of [%s]

What it means

The supervisor's reset endpoint (resetDataSourceMetadata) accepts a DataSourceMetadata describing what to reset. If the requested metadata is not the type the supervisor's IOConfig expects (checkSourceMetadataMatch fails), the reset cannot proceed and an IAE is thrown naming the received class.

Solutions

  1. Send reset metadata of the class matching the supervisor's stream type (e.g. SeekableStreamDataSourceMetadata subclass for Kafka/Kinesis)
  2. Verify the datasource name in the reset request targets the intended supervisor
  3. Check the supervisor's ioConfig.stream/type before constructing reset metadata

Example fix

// before: wrong metadata type for a Kinesis supervisor
client.post('/druid/indexer/v1/supervisor/kinesis-svc/reset', new KafkaDataSourceMetadata(...));
// after
client.post('/druid/indexer/v1/supervisor/kinesis-svc/reset',
    new KinesisDataSourceMetadata(new SeekableStreamEndSequenceNumbers<>(stream, offsets)));
Defensive patterns

Strategy: validation

Validate before calling

if (!metadata.getClass().equals(expectedMetadataClass)) {
  throw new IllegalArgumentException("Reset metadata must be of type " + expectedMetadataClass.getSimpleName());
}

Type guard

boolean isMatchingMetadata(DataSourceMetadata m, Class<? extends DataSourceMetadata> required) {
  return required.isInstance(m);
}

Prevention

When it happens

Trigger: POSTing reset metadata whose class does not match the supervisor's source type — e.g. sending KafkaDataSourceMetadata to a Kinesis supervisor, or a generic DataSourceMetadata to a seekable-stream supervisor.

Common situations: Copy-pasted reset API calls between supervisors of different stream types; automation scripts resetting the wrong datasource; migrating ingestion from Kafka to Kinesis with old reset payloads.

Understand the failure class

Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.

Related errors


AI-assisted analysis of apache/druid@9b90983fd2 (2026-09-07). Data as JSON: /api/errors/f8e31dc6e93f0640. Report an issue: GitHub.

Appendix: source

Thrown at indexing-service/src/main/java/org/apache/druid/indexing/seekablestream/supervisor/SeekableStreamSupervisor.java:2156

    if (dataSourceMetadata == null) {
      // Reset everything
      boolean result = indexerMetadataStorageCoordinator.deleteDataSourceMetadata(supervisorId);
      log.info("Reset supervisor[%s] for dataSource[%s] - dataSource metadata entry deleted? [%s]", supervisorId, dataSource, result);
      activelyReadingTaskGroups.values()
                               .forEach(group -> killTasksInGroup(
                                   group,
                                   "DataSourceMetadata is not found while reset"
                               ));
      activelyReadingTaskGroups.clear();
      partitionGroups.clear();
      partitionOffsets.clear();
      if (ioConfig.isBounded()) {
        initializeBoundedPartitionGroups();
        stateManager.maybeSetState(SupervisorStateManager.BasicState.RUNNING);
      }
    } else {
      if (!checkSourceMetadataMatch(dataSourceMetadata)) {
        throw new IAE(
            "Datasource metadata instance does not match required, found instance of [%s]",
            dataSourceMetadata.getClass()
        );
      }
      log.info("Reset supervisor[%s] for dataSource[%s] with metadata[%s]", supervisorId, dataSource, dataSourceMetadata);
      // Reset only the partitions in dataSourceMetadata if it has not been reset yet
      @SuppressWarnings("unchecked")
      final SeekableStreamDataSourceMetadata<PartitionIdType, SequenceOffsetType> resetMetadata =
          (SeekableStreamDataSourceMetadata<PartitionIdType, SequenceOffsetType>) dataSourceMetadata;

      if (resetMetadata.getSeekableStreamSequenceNumbers().getStream().equals(ioConfig.getStream())) {
        // metadata can be null
        final DataSourceMetadata metadata = indexerMetadataStorageCoordinator.retrieveDataSourceMetadata(supervisorId);
        if (metadata != null && !checkSourceMetadataMatch(metadata)) {
          throw new IAE(
              "Datasource metadata instance does not match required, found instance of [%s]",
              metadata.getClass()
          );

View on GitHub (pinned to 9b90983fd2)