prestodb/presto · error · PrestoException

DRUID_DEEP_STORAGE_ERROR

DRUID_DEEP_STORAGE_ERROR

Error message

Error reading from %s at position %s

What it means

Thrown by Druid's HdfsDataInputSource when an IOException occurs while reading bytes of a Druid segment from HDFS deep storage at a given position. It wraps the underlying I/O failure in a DRUID_DEEP_STORAGE_ERROR so callers see a uniform error for deep-storage read problems.

Source

Thrown at presto-druid/src/main/java/com/facebook/presto/druid/segment/HdfsDataInputSource.java:84

        readFully(position, buffer, 0, buffer.length);
    }

    @Override
    public void readFully(long position, byte[] buffer, int bufferOffset, int bufferLength)
    {
        long start = System.nanoTime();
        readInternal(position, buffer, bufferOffset, bufferLength);

        readTimeNanos += System.nanoTime() - start;
    }

    private void readInternal(long position, byte[] buffer, int bufferOffset, int bufferLength)
    {
        try {
            inputStream.readFully(position, buffer, bufferOffset, bufferLength);
        }
        catch (IOException e) {
            throw new PrestoException(DRUID_DEEP_STORAGE_ERROR, format("Error reading from %s at position %s", id, position), e);
        }
    }

    @Override
    public void close()
            throws IOException
    {
        inputStream.close();
    }
}

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Check underlying HDFS cluster health (hdfs fsck on the segment path) and datanode logs
  2. Verify the segment file exists and is not truncated: hdfs dfs -ls -h <segment path>
  3. Retry the query; transient datanode/replication failures often clear
  4. Validate druid.storage.storage-directory and deep-storage connectivity config
  5. Re-ingest or re-publish the affected Druid segment if corrupted

Example fix

// before
inputStream.readFully(position, buffer, bufferOffset, bufferLength);
// after
try (FileSystem fs = path.getFileSystem(conf)) {
    if (!fs.exists(path)) { throw new PrestoException(DRUID_DEEP_STORAGE_ERROR, "Segment missing: " + path); }
    inputStream.readFully(position, buffer, bufferOffset, bufferLength);
}
Defensive patterns

Strategy: try-catch

Validate before calling

// caller-side pre-check
long len = fileSystem.getFileStatus(segmentPath).getLen();
if (position + bufferLength > len) {
    throw new PrestoException(DRUID_DEEP_STORAGE_ERROR, "Read past end of segment: " + segmentPath);
}

Type guard

function isDeepStorageReadError(e) { return e instanceof PrestoException && e.getErrorCode().getName().equals('DRUID_DEEP_STORAGE_ERROR'); }

Try / catch

try {
    segmentReader.readFully(position, buffer, 0, buffer.length);
} catch (PrestoException e) {
    if (e.getErrorCode().getName().equals("DRUID_DEEP_STORAGE_ERROR")) {
        // log position + segment id, retry or failover to replica segment
    } else { throw e; }
}

Prevention

When it happens

Trigger: readInternal(position, buffer, ...) calls inputStream.readFully(...) (via readFully) and the underlying HDFS/local input stream throws IOException — e.g. block missing, datanode failure, truncated segment file, permission error.

Common situations: HDFS NameNode/DataNode outages, segment files deleted or moved by retention jobs, replication undercount during node failure, corrupted or truncated segments on deep storage, misconfigured HDFS federation paths in Druid deep storage config.

Related errors


AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04). Data as JSON: /api/errors/e56873cc75205e7b. Report an issue: GitHub.