apache/druid · error · SamplerException

Exception while seeking to the

Error message

Exception while seeking to the [%s] offset of partitions in topic [%s]: %s

What it means

RecordSupplierInputSource.assignAndSeek() positions the record supplier (e.g. Kafka or Kinesis consumer) at the earliest or latest offset of the requested topic/stream partitions for sampling. If any seek operation throws, it wraps the root cause into a SamplerException carrying the offset mode, topic, and root-cause message. This aborts data sampling for supervisor spec ingestion.

Solutions

  1. Read the root-cause message in the exception and fix the underlying broker/connection issue (wrong topic name, missing partitions, auth failure).
  2. Verify the topic/stream exists and the listed partitions are valid: `kafka-topics.sh --describe --topic <topic>`.
  3. Check network connectivity and security config (bootstrap servers, SASL/SSL, Kinesis region/credentials).
  4. Retry sampling after the broker recovers; confirm the supervisor spec's topic and partitions match reality.

Example fix

// before: sampling a non-existent topic
"spec": {"ioConfig": {"topic": "kafak-events", "partitions": [0, 1]}}
// after: corrected topic name
"spec": {"ioConfig": {"topic": "kafka-events", "partitions": [0, 1]}}
Defensive patterns

Strategy: validation

Validate before calling

// verify topic and partitions before sampling
kafka-topics.sh --bootstrap-server broker:9092 --describe --topic <topic>
# ensure requested partitions exist and broker is reachable

Try / catch

try { sample(spec); } catch (SamplerException e) { log.error("Sampling failed: {}", Throwables.getRootCause(e).getMessage()); throw new ValidationException("Fix topic/broker config before sampling", e); }

Prevention

When it happens

Trigger: Calling the sampling endpoint (POST /druid/indexer/v1/sampler) whose ioConfig has useEarliestSequenceNumber true/false; recordSupplier.seekToEarliest or seekToLatest throws because partitions don't exist, the broker is unreachable, the consumer has no permission, or offsets are out of range.

Common situations: Typo in topic name or partition numbers; topic auto-creation disabled and topic absent; Kafka broker auth (SASL/ACLs) denying the consumer; Kinesis shard being split/merged mid-seek; network/firewall issues between the router/overlord and brokers.

Understand the failure class

Background: ECONNREFUSED and "connection refused" / "could not connect to server" errors: what they mean and how to fix them — this error's family across 44 libraries.

Related errors


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

Appendix: source

Thrown at indexing-service/src/main/java/org/apache/druid/indexing/seekablestream/RecordSupplierInputSource.java:95

  private void assignAndSeek(RecordSupplier<PartitionIdType, SequenceOffsetType, RecordType> recordSupplier)
  {
    try {
      final Set<StreamPartition<PartitionIdType>> partitions = recordSupplier
          .getPartitionIds(topic)
          .stream()
          .map(partitionId -> StreamPartition.of(topic, partitionId))
          .collect(Collectors.toSet());

      recordSupplier.assign(partitions);

      if (useEarliestOffset) {
        recordSupplier.seekToEarliest(partitions);
      } else {
        recordSupplier.seekToLatest(partitions);
      }
    }
    catch (Exception e) {
      throw new SamplerException(
          e,
          "Exception while seeking to the [%s] offset of partitions in topic [%s]: %s",
          useEarliestOffset ? "earliest" : "latest",
          topic,
          Throwables.getRootCause(e).getMessage()
      );
    }
  }

  @Override
  public boolean isSplittable()
  {
    return false;
  }

  @Override
  public boolean needsFormat()
  {

View on GitHub (pinned to 9b90983fd2)