apache/cassandra · critical · FSWriteError
No configured data directory contains enough space to write
Error message
No configured data directory contains enough space to write " + writeSize + " bytes
What it means
Directories.getWriteableLocationAsFile(writeSize) picks a data directory that can hold a write of the given size. If no configured data directory passes the disk-usage policy (has enough free space after writeSize, not blacklisted, not read-only), it throws FSWriteError wrapping an IOException stating no directory contains enough space.
Source
Thrown at src/java/org/apache/cassandra/db/Directories.java:367
* Do not use this method in production code.
*
* @throws FSWriteError if all directories are disallowed.
*/
public File getDirectoryForNewSSTables()
{
return getWriteableLocationAsFile(-1L);
}
/**
* Returns an allowed directory that _currently_ has {@code writeSize} bytes as usable space.
*
* @throws FSWriteError if all directories are disallowed.
*/
public File getWriteableLocationAsFile(long writeSize)
{
File location = getLocationForDisk(getWriteableLocation(writeSize));
if (location == null)
throw new FSWriteError(new IOException("No configured data directory contains enough space to write " + writeSize + " bytes"), "");
return location;
}
/**
* Returns a data directory to load the file {@code sourceFile}. If the sourceFile is on same disk partition as any
* data directory then use that one as data directory otherwise use {@link #getWriteableLocationAsFile(long)} to
* find suitable data directory.
*
* Also makes sure returned directory is not disallowed.
*
* @throws FSWriteError if all directories are disallowed.
*/
public File getWriteableLocationToLoadFile(final File sourceFile)
{
try
{
final FileStore srcFileStore = Files.getFileStore(sourceFile.toPath());
for (final File dataPath : dataPaths)View on GitHub (pinned to 88fd0f6a0e)
Solutions
- Free space on the data directories (delete snapshots via `nodetool clearsnapshot`, run compaction to reclaim space) or add/expand disks.
- Move data_file_directories to larger volumes and restart, or rebalance tokens/tables to nodes with space.
- Lower disk_usage_percent settings only as a stopgap; verify with `nodetool diskusage` / `df -h`.
- Reduce flush/compaction write sizes (smaller compaction strategies, e.g. LCS/STCS tuning) if a single operation is larger than any disk.
Example fix
// cassandra.yaml before data_file_directories: [/var/lib/cassandra/data] // after: distribute across larger volumes data_file_directories: - /mnt/disk1/cassandra/data - /mnt/disk2/cassandra/data
Defensive patterns
Strategy: validation
Validate before calling
long usable = file.getTotalSpace() - file.getUsableSpace();
if (writeSize > file.getUsableSpace() * (1 - 0.10)) // keep 10% headroom
throw new IllegalStateException("Insufficient disk space for " + writeSize);
Try / catch
try {
File dir = directories.getWriteableLocationAsFile(writeSize);
} catch (FSWriteError e) {
if (e.getMessage().contains("No configured data directory contains enough space"))
clearSnapshotsAndAlert(); // nodetool clearsnapshot, page on-call
throw e;
}
Prevention
- Alert on disk usage well before the fail threshold (e.g. 80%).
- Schedule `nodetool clearsnapshot` cleanup; snapshots silently consume space.
- Spread data_file_directories across independent large volumes.
- Size disks for the largest expected compaction/flush write.
When it happens
Trigger: Flushing a memtable, compacting, or writing an SSTable whose estimated size exceeds the free space of every configured data_file_directories location, taking into account disk_usage_percent_warn/fail thresholds and read-only/blacklisted disks.
Common situations: Data directories actually full or nearly full (small disk, unbounded growth); all data dirs on one small partition; incorrect data_file_directories config pointing to tiny mounts; disk failures leaving only undersized volumes; large compactions or huge flushes after big writes.
Understand the failure class
Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.
Related errors
- Unsupported disk access mode for background_write_disk_acces
- Not enough space for compaction (%s) of %s.%s, estimated sst
- Not enough space to write %s to %s (%s available)
- Not enough disk space to store %s
- Only {} free across all data volumes. Consider adding more c
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/bff7d7bf554b6204.
Report an issue: GitHub.