Details
-
Bug
-
Status: In Progress
-
Normal
-
Resolution: Unresolved
-
None
-
Normal
-
Low Hanging Fruit
Description
The CompactionAwareWriter_getWriteDirectory throws RuntimeException:
public Directories.DataDirectory getWriteDirectory(Iterable<SSTableReader> sstables, long estimatedWriteSize) { File directory = null; for (SSTableReader sstable : sstables) { if (directory == null) directory = sstable.descriptor.directory; if (!directory.equals(sstable.descriptor.directory)) { logger.trace("All sstables not from the same disk - putting results in {}", directory); break; } } Directories.DataDirectory d = getDirectories().getDataDirectoryForFile(directory); if (d != null) { long availableSpace = d.getAvailableSpace(); if (availableSpace < estimatedWriteSize) throw new RuntimeException(String.format("Not enough space to write %s to %s (%s available)", FBUtilities.prettyPrintMemory(estimatedWriteSize), d.location, FBUtilities.prettyPrintMemory(availableSpace))); logger.trace("putting compaction results in {}", directory); return d; } d = getDirectories().getWriteableLocation(estimatedWriteSize); if (d == null) throw new RuntimeException(String.format("Not enough disk space to store %s", FBUtilities.prettyPrintMemory(estimatedWriteSize))); return d; }
However, the thrown exception does not trigger the failure policy. CASSANDRA-11448 fixed a similar problem. The buggy code is:
protected Directories.DataDirectory getWriteDirectory(long writeSize) { Directories.DataDirectory directory = getDirectories().getWriteableLocation(writeSize); if (directory == null) throw new RuntimeException("Insufficient disk space to write " + writeSize + " bytes"); return directory; }
The fixed code is:
protected Directories.DataDirectory getWriteDirectory(long writeSize) { Directories.DataDirectory directory = getDirectories().getWriteableLocation(writeSize); if (directory == null) throw new FSWriteError(new IOException("Insufficient disk space to write " + writeSize + " bytes"), ""); return directory; }
The fixed code throws FSWE and triggers the failure policy.