apache/hadoop · error · FileAlreadyExistsException

Failed to rename %s to %s, file already exists or not empty!

Error message

Failed to rename %s to %s, file already exists or not empty!

What it means

The primary ZombieJob constructor requires a non-null LoggedJob and throws IllegalArgumentException('job is null') otherwise. A ZombieJob is a simulated reincarnation of one specific dead job; without the logged job record there is nothing to simulate, so the guard fails fast. Because LoggedJob normally comes from deserializing a rumen JSON trace, a null usually means the trace lookup returned nothing rather than a caller explicitly passing null.

Source

Thrown at hadoop-cloud-storage-project/hadoop-bos/src/main/java/org/apache/hadoop/fs/bos/BaiduBosFileSystem.java:804

      LOG.debug("Parent directory {} does not exist "
          + "or will be implicitly created during rename",
          dstPath.getParent());
    } else {
      if (dstStatus.isDirectory()) {
        dstPath = new Path(dstPath, srcPath.getName());
        FileStatus status;
        try {
          status = getFileStatus(dstPath);
        } catch (FileNotFoundException fnde) {
          status = null;
        }
        if (status != null) {
          if (status.isFile()) {
            LOG.debug("Deleting existing destination "
                + "file {} before rename", dstPath);
            delete(dstPath, false);
          } else {
            throw new FileAlreadyExistsException(
                String.format(
                    "Failed to rename %s to %s, "
                        + "file already exists or not empty!",
                    srcPath, dstPath));
          }
        }
      } else {
        LOG.debug("Deleting existing destination "
            + "file {} before rename", dstPath);
        delete(dstPath, false);
      }
    }

    store.rename(pathToKey(srcPath), pathToKey(dstPath),
        srcStatus.isFile());
    return true;
  }

View on GitHub (pinned to 2add963021)

Solutions

  1. Null-check the LoggedJob obtained from the trace before constructing the ZombieJob and handle 'not found' explicitly (skip, or fail with your own contextual message).
  2. Validate the trace file is a real rumen JSON trace and actually contains the job you are looking for (inspect the top-level array/object).
  3. If you need a synthetic job without logged data, ZombieJob is the wrong tool — construct LoggedJob with minimal fields rather than passing null.

Example fix

// before
LoggedJob job = getJobByName(trace, jobName); // returns null when absent
JobStory story = new ZombieJob(job, cluster); // IllegalArgumentException

// after
LoggedJob job = getJobByName(trace, jobName);
if (job == null) {
  throw new IOException("Job '" + jobName + "' not found in trace " + tracePath);
}
JobStory story = new ZombieJob(job, cluster);
Defensive patterns

Strategy: validation

Validate before calling

static ZombieJob newZombieJob(LoggedJob job, ClusterStory cluster, long seed) {
  if (job == null) {
    throw new NoSuchElementException(
        "No logged job to simulate; check the trace lookup");
  }
  return new ZombieJob(job, cluster, seed);
}

Type guard

static boolean hasLoggedJob(LoggedJob job) {
  return job != null;
}

Prevention

When it happens

Trigger: new ZombieJob(null, cluster, seed) or new ZombieJob(null, cluster); looking up a job in a trace by name/id, getting null back (job not found), and passing it straight to the constructor; JSON deserialization returning null for an absent record.

Common situations: Trace-driven simulators (Mumak) loading a job trace where the requested job index/id does not exist; empty or truncated rumen trace files; a Map over trace entries where a filter/null creeps in.

Related errors


AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22). Data as JSON: /api/errors/b0c3c57e2b48d235. Report an issue: GitHub.