apache/cassandra · error · IllegalArgumentException

%s exists but is not writable

Error message

%s exists but is not writable

What it means

StressCQLSSTableWriter.Builder.inDirectory(File) also requires the directory to be writable, since SSTables must be written into it. It throws IllegalArgumentException when the File exists but the process lacks write permission on it.

Source

Thrown at tools/stress/src/org/apache/cassandra/io/sstable/StressCQLSSTableWriter.java:409

            return inDirectory(new File(directory));
        }

        /**
         * The directory where to write the sstables (mandatory option).
         * <p>
         * This is a mandatory option.
         *
         * @param directory the directory to use, which should exist and be writable.
         * @return this builder.
         *
         * @throws IllegalArgumentException if {@code directory} doesn't exist or is not writable.
         */
        public Builder inDirectory(File directory)
        {
            if (!directory.exists())
                throw new IllegalArgumentException(directory + " doesn't exists");
            if (!directory.canWrite())
                throw new IllegalArgumentException(directory + " exists but is not writable");

            directoryList.add(directory);
            return this;
        }

        /**
         * A pre-instanciated ColumnFamilyStore
         * <p>
         * This is can be used in place of inDirectory and forTable
         *
         * @see #inDirectory(File)
         *
         * @param cfs the list of directories to use, which should exist and be writable.
         * @return this builder.
         *
         * @throws IllegalArgumentException if a directory doesn't exist or is not writable.
         */
        public Builder withCfs(ColumnFamilyStore cfs)

View on GitHub (pinned to 88fd0f6a0e)

Solutions

  1. chmod/chown the directory so the running user can write to it.
  2. Choose a different output directory the user can write to (e.g. under the user's home).
  3. Test with dir.canWrite() before calling inDirectory.
  4. Check whether the mount is read-only and remount read-write.

Example fix

// before
builder.inDirectory(new File("/var/lib/cassandra/data")); // owned by cassandra user
// after
builder.inDirectory(new File(System.getProperty("java.io.tmpdir"), "sstable-out"));
Defensive patterns

Strategy: validation

Validate before calling

File dir = new File(path);
if (!dir.canWrite()) throw new IllegalStateException("not writable: " + dir);
builder.inDirectory(dir);

Try / catch

try { builder.inDirectory(dir); }
catch (IllegalArgumentException e) { throw new IllegalStateException("fix permissions on " + dir, e); }

Prevention

When it happens

Trigger: Calling inDirectory(File) with an existing directory that the current OS user cannot write to (e.g. root-owned directory, read-only mount, restrictive umask).

Common situations: Running the stress tool as a non-root user while the output dir is root-owned; read-only container filesystem or volume; NFS mount exported read-only.

Understand the failure class

Background: "Permission denied" / "Failed to write" file errors: why a library can't write its files to disk (EACCES, EPERM, ENOSPC) and how to fix them — this error's family across 43 libraries.

Related errors


AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10). Data as JSON: /api/errors/e826b24a706e6a74. Report an issue: GitHub.