apache/cassandra · error · IllegalStateException

History file is not readable.%n

Error message

History file %s is not readable.%n

What it means

History.validateHistoryFile's final check confirms the file is readable by the current user; otherwise it throws IllegalStateException('History file <path> is not readable.'). This blocks the history command from opening the file for reading.

Solutions

  1. Fix ownership/permissions: `sudo chown $(whoami) ~/.cassandra/nodetool.history && chmod 600 ~/.cassandra/nodetool.history`
  2. Run nodetool as the user who owns the history file
  3. Use `sudo -u <owner> nodetool history` to run under the file's owner

Example fix

// before
sudo nodetool history   # runs as root, reads root's unreadable history
// after
sudo chown cassandra:cassandra ~/.cassandra/nodetool.history && nodetool history
Defensive patterns

Strategy: validation

Validate before calling

# check readability and ownership before invoking
HIST="$HOME/.cassandra/nodetool.history"
[ -r "$HIST" ] || { echo "history file not readable: $HIST"; exit 1; }

Try / catch

try { runNodetool("history"); } catch (IllegalStateException e) {
    if (e.getMessage().contains("is not readable")) { log("chmod/chown the history file or run as its owner"); return; }
    throw e;
}

Prevention

When it happens

Trigger: Running nodetool as a different user than the one who created ~/.cassandra/nodetool.history (e.g. via sudo), or permissions were tightened to 0600 owned by another account.

Common situations: Using sudo without -E/-H so HOME changes; multi-user nodes where each operator runs nodetool but the history file was created by root; backup tools resetting permissions.

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/cassandra@88fd0f6a0e (2026-09-10). Data as JSON: /api/errors/c33fa1811e3bc3d5. Report an issue: GitHub.

Appendix: source

Thrown at src/java/org/apache/cassandra/tools/nodetool/History.java:94

    }

    /**
     * Nodetool is appending command to history file before it is executed so us checking on its
     * existence and validating it is not technically necessary however nodetool is also swallowing
     * all errors when it was not succesful in appending to the history file so better to check here in that case.
     *
     * @param historyFile file to check that it is actually a file which exists and it is readable
     */
    void validateHistoryFile(File historyFile)
    {
        if (!historyFile.exists())
            throw new IllegalStateException(String.format("History file %s does not exist.%n", historyFile.absolutePath()));

        if (!historyFile.isFile())
            throw new IllegalStateException(String.format("History file %s is not a file.%n", historyFile.absolutePath()));

        if (!historyFile.isReadable())
            throw new IllegalStateException(String.format("History file %s is not readable.%n", historyFile.absolutePath()));
    }
}

View on GitHub (pinned to 88fd0f6a0e)