apache/hadoop · warning · IOException
BlockReader failed to seek to {}. Instead, it seeked to {}.
Error message
BlockReader failed to seek to {}. Instead, it seeked to {}. What it means
When seek() lands inside the currently buffered block (pos <= targetPos <= blockEnd and diff <= blockReader.available()), the client 'seeks' by calling blockReader.skip(diff) and expects pos to land exactly on targetPos. If the block reader's skip returns something else, the client logs this warning and throws IOException internally - but the surrounding catch block swallows that IOException (unless the thread was interrupted), resets blockEnd = -1, and lets the next read() open a fresh block reader. So this is a symptom of a buggy or edge-case BlockReader skip() implementation (the code comment says 'most likely a bug'), and the stream normally self-recovers on the next read.
Source
Thrown at hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DFSInputStream.java:1670
//
// If this seek is to a positive position in the current
// block, and this piece of data might already be lying in
// the TCP buffer, then just eat up the intervening data.
//
int diff = (int)(targetPos - pos);
if (diff <= blockReader.available()) {
try {
pos += blockReader.skip(diff);
if (pos == targetPos) {
done = true;
} else {
// The range was already checked. If the block reader returns
// something unexpected instead of throwing an exception, it is
// most likely a bug.
String errMsg = "BlockReader failed to seek to " +
targetPos + ". Instead, it seeked to " + pos + ".";
DFSClient.LOG.warn(errMsg);
throw new IOException(errMsg);
}
} catch (IOException e) {//make following read to retry
DFSClient.LOG.debug("Exception while seek to {} from {} of {} from "
+ "{}", targetPos, getCurrentBlock(), src, currentNode, e);
checkInterrupted(e);
}
}
}
if (!done) {
pos = targetPos;
blockEnd = -1;
}
}
/**
* Same as {@link #seekToNewSource(long)} except that it does not exclude
* the current datanode and might connect to the same node.
*/View on GitHub (pinned to 2add963021)
Solutions
- Upgrade the cluster/client hadoop-client jars to the latest patch release of your branch - multiple BlockReader skip() fixes have landed across 2.x and 3.x.
- As a workaround, disable short-circuit reads (dfs.client.read.shortcircuit=false on the client) to force the well-tested remote block reader path.
- Capture org.apache.hadoop.hdfs.DFSClient DEBUG logs (the catch block logs 'Exception while seek to ...' with the underlying cause) and the exact Hadoop version, and check/file a JIRA if the warning recurs.
- No application change is required: the fallback (blockEnd = -1) makes the next read re-open the block reader at the right offset; treat repeated warnings as a performance issue, not a correctness one.
Defensive patterns
Strategy: fallback
Prevention
- Keep hadoop-client at the latest patch level of your branch - BlockReader skip() fixes ship in patches.
- If the warning recurs, toggle dfs.client.read.shortcircuit=false to test whether a short-circuit reader is the culprit.
- Enable DEBUG on org.apache.hadoop.hdfs.DFSClient to capture the underlying cause logged by the catch block.
- Treat the warning as a performance symptom: the client already falls back by resetting blockEnd and re-opening the reader on the next read.
When it happens
Trigger: Forward seek within the current block whose diff fits in blockReader.available(), combined with a BlockReader whose skip() returns fewer/more bytes than requested - historically seen with short-circuit or encrypted block readers in specific Hadoop versions. Rarely triggered by user code; requires the reader implementation itself to misbehave.
Common situations: Reports clustered around specific hadoop-client patch levels with short-circuit reads (dfs.client.read.shortcircuit=true) or encrypted (AES-CTR) block readers; often a one-line WARN in logs with reads continuing normally afterwards; occasionally resurfaces repeatedly on heavily seeked workloads (index files, record readers).
Related errors
- failed to allocate new BlockReader at position {}
- Cannot seek to negative offset
- Stream is closed!
- Cannot seek after EOF
- ${className} does not support seek.
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/f57434248198d9b2.
Report an issue: GitHub.