apache/hadoop · error · IOException
Could not find image with txid " + txid
Error message
Could not find image with txid " + txid
What it means
ImageServlet's GETIMAGE handling throws IOException("Could not find image with txid N") when the request asks for a specific transaction-id fsimage and NNStorage.getFsImage(txid, {IMAGE, IMAGE_ROLLBACK}) finds no matching fsimage_<txid> file in the NameNode's storage directories. The NameNode simply does not retain (or never had) an image at that txid.
Source
Thrown at hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/ImageServlet.java:158
validateRequest(context, conf, request, response, nnImage,
parsedParams.getStorageInfoString());
UserGroupInformation.getCurrentUser().doAs(new PrivilegedExceptionAction<Void>() {
@Override
public Void run() throws Exception {
if (parsedParams.isGetImage()) {
long txid = parsedParams.getTxId();
File imageFile = null;
String errorMessage = "Could not find image";
if (parsedParams.shouldFetchLatest()) {
imageFile = nnImage.getStorage().getHighestFsImageName();
} else {
errorMessage += " with txid " + txid;
imageFile = nnImage.getStorage().getFsImage(txid,
EnumSet.of(NameNodeFile.IMAGE, NameNodeFile.IMAGE_ROLLBACK));
}
if (imageFile == null) {
throw new IOException(errorMessage);
}
CheckpointFaultInjector.getInstance().beforeGetImageSetsHeaders();
long start = monotonicNow();
serveFile(imageFile);
if (metrics != null) { // Metrics non-null only when used inside name node
long elapsed = monotonicNow() - start;
metrics.addGetImage(elapsed);
}
} else if (parsedParams.isGetEdit()) {
long startTxId = parsedParams.getStartTxId();
long endTxId = parsedParams.getEndTxId();
File editFile = nnImage.getStorage()
.findFinalizedEditsFile(startTxId, endTxId);
long start = monotonicNow();
serveFile(editFile);
View on GitHub (pinned to 2add963021)
Solutions
- Request the latest image instead of a fixed txid (GetImageParams 'latest' flag, e.g. getimage?getimage=1&latest=1)
- Verify which images exist: ls <dfs.namenode.name.dir>/current/fsimage_* or check NameNode JMX mostRecentCheckpointTxid
- Re-run the checkpoint or bootstrap so the requester and the NameNode agree on the current txid
- Increase dfs.namenode.num.checkpoints.retained if requesters legitimately need older checkpoints
Example fix
# before: pinned txid that was purged curl -f 'http://nn:9870/getimage?getimage=1&txid=1234' # -> IOException: Could not find image with txid 1234 # after: fetch latest TXID=$(curl -s http://nn:9870/jmx | jq -r '.beans[]|select(.name=="Hadoop:service=NameNode,name=NameNodeInfo").MostRecentCheckpointTxId') curl -f "http://nn:9870/getimage?getimage=1&txid=$TXID"
Defensive patterns
Strategy: validation
Validate before calling
// Before requesting a specific txid, confirm the NN retains it
long latest = jmxMostRecentCheckpointTxid(nnJmxUrl); // NameNodeInfo bean
if (requestedTxid > latest) {
requestedTxid = latest; // or fail: request is for a purged checkpoint
}
curl -f "http://nn:9870/getimage?getimage=1&txid=$requestedTxid" Try / catch
catch (IOException e) {
if (e.getMessage() != null && e.getMessage().contains("Could not find image with txid")) {
imageFile = fetchLatest(); // fall back to latest=1 transfer
if (imageFile == null) { throw e; } // NN storage genuinely inconsistent
} else { throw e; }
} Prevention
- Prefer latest-image requests (latest=1) unless a specific txid is required
- Keep dfs.namenode.num.checkpoints.retained large enough for the slowest checkpoint consumer
- After NN storage replacement/format, restart SecondaryNameNode/Standby so txid expectations resync
When it happens
Trigger: Requesting a checkpoint txid already purged by retention (dfs.namenode.num.checkpoints.retained); asking for an IMAGE_ROLLBACK file when no rollback checkpoint exists; SecondaryNameNode/Standby bootstrapping with a stale txid after the Active's storage changed (restart, fresh format, restored directory).
Common situations: SNN checkpoint failing right after NN storage was replaced or reformatted; too few retained checkpoints for a slow/down SNN; hand-crafted transfer URLs or scripts pinning an old txid.
Related errors
- The length of the feature flag section was negative at {} by
- Content-Length header is not provided by the namenode when t
- Safe mode should be turned ON in order to create namespace i
- NameNode initialization not yet complete. FSImage has not be
- GetImage failed. " + StringUtils.stringifyException(t)
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/6f3bf36ce7a62e4c.
Report an issue: GitHub.