apache/druid · error · RuntimeException

Error occurred while trying to read uri:

Error message

Error occurred while trying to read uri: 

What it means

InputEntityIteratingReader.read wraps any IOException raised while opening or streaming an InputEntity in a RuntimeException prefixed with 'Error occurred while trying to read uri: <uri>' (or a generic message when the entity has no URI). It marks the fetch of that entity as failed so the task can report the offending source.

Source

Thrown at processing/src/main/java/org/apache/druid/data/input/impl/InputEntityIteratingReader.java:79

    this.inputFormat = inputFormat;
    this.sourceIterator = (CloseableIterator<InputEntity>) sourceIterator;
    this.systemFieldDecoratorFactory = systemFieldDecoratorFactory;
    this.temporaryDirectory = temporaryDirectory;
  }

  @Override
  public CloseableIterator<InputRow> read(InputStats inputStats)
  {
    return createIterator(entity -> {
      // InputEntityReader is stateful and so a new one should be created per entity.
      final Function<InputRow, InputRow> systemFieldDecorator = systemFieldDecoratorFactory.decorator(entity);
      try {
        final InputEntity entityToRead = inputStats == null ? entity : new BytesCountingInputEntity(entity, inputStats);
        final InputEntityReader reader = inputFormat.createReader(inputRowSchema, entityToRead, temporaryDirectory);
        return reader.read().map(systemFieldDecorator);
      }
      catch (IOException e) {
        throw new RuntimeException(entity.getUri() != null ?
                                   "Error occurred while trying to read uri: " + entity.getUri() :
                                   "Error occurred while reading input", e);
      }
    });
  }

  @Override
  public CloseableIterator<InputRowListPlusRawValues> sample()
  {
    return createIterator(entity -> {
      // InputEntityReader is stateful and so a new one should be created per entity.
      final Function<InputRow, InputRow> systemFieldDecorator = systemFieldDecoratorFactory.decorator(entity);
      try {
        final InputEntityReader reader = inputFormat.createReader(inputRowSchema, entity, temporaryDirectory);
        return reader.sample()
            .map(i -> InputRowListPlusRawValues.ofList(i.getRawValuesList(),
                i.getInputRows() == null
                    ? null

View on GitHub (pinned to 9b90983fd2)

Solutions

  1. Check the wrapped 'Caused by' IOException for the root cause (status code, UnknownHostException, timeout)
  2. Verify the URI is reachable and authorized from the Druid data server (curl the URI from that host)
  3. Retry the task — transient network errors are common; consider retries in the input source config
  4. For HTTP sources, confirm server availability and Range/keep-alive behavior; for S3, verify credentials and object existence
Defensive patterns

Strategy: retry

Validate before calling

// Pre-flight check of each URI from the ingestion host
for (URI uri : uris) {
    URLConnection c = uri.toURL().openConnection();
    try (InputStream in = c.getInputStream()) { in.read(); } // throws early if unreachable
}

Try / catch

try { iterator.forEachRemaining(...); } catch (RuntimeException e) { if (e.getMessage().startsWith("Error occurred while trying to read uri:")) { log URI; schedule retry; } else throw e; }

Prevention

When it happens

Trigger: Any IOException from inputFormat.createReader(...).read() — unreachable host, HTTP 404/403, socket timeout, prematurely closed connection, or unreadable local file — surfaces through this wrapper in InputEntityIteratingReader.read.

Common situations: Expired or wrong S3/HTTP credentials; file deleted between listing and read; DNS or firewall failures from Druid middle managers; network blips during long ingestion tasks.

Understand the failure class

Background: "failed to read file", EACCES, ENOENT and "could not read <path>" errors: when a program can't read a file from disk — this error's family across 49 libraries.

Related errors


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