Skip to content

Commit 55edc34

Browse files
CASSANDRA-21134: Enable background-write Direct I/O in cassandra_latest config
Add background_write_disk_access_mode: direct to cassandra_latest.yaml so new-install/latest configurations exercise Direct I/O by default, and keep the test latest config in sync (test/conf/latest_diff.yaml and the DTEST_JVM_DTESTS_USE_LATEST block in InstanceConfig.java). The cassandra.yaml default remains standard. CQLTester.InMemory installs a global jimfs filesystem, which cannot do Direct I/O (no FileStore.getBlockSize(), rejects ExtendedOpenOption.DIRECT), so pin in-memory tests to buffered writes to keep the latest config green.
1 parent 647ed4f commit 55edc34

5 files changed

Lines changed: 25 additions & 2 deletions

File tree

conf/cassandra_latest.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -700,6 +700,21 @@ commitlog_disk_access_mode: auto
700700
# - direct: use direct I/O for compaction reads, bypassing the OS page cache
701701
# compaction_read_disk_access_mode: auto
702702

703+
# Set the disk access mode for writing compressed SSTables during background operations
704+
# (compaction, streaming, cleanup, repair, etc.). The allowed values are:
705+
# - standard: use buffered I/O (default)
706+
# - direct: use direct I/O, bypassing the OS page cache
707+
# Note: Only applies to compressed tables. Uncompressed tables always use buffered I/O.
708+
# Note: Memtable flushes always use buffered I/O regardless of this setting, as flushed
709+
# data benefits from page cache for subsequent reads.
710+
background_write_disk_access_mode: direct
711+
712+
# Size of the in-memory staging buffer for Direct IO background writes. Trades off syscall
713+
# frequency against per-flush blocking latency on the compaction thread.
714+
# Aligned up to filesystem block size; auto-expands to fit a single compressed chunk + CRC
715+
# + one block when chunk_length exceeds this value.
716+
# direct_write_buffer_size: 1MiB
717+
703718
# Compression to apply to SSTables as they flush for compressed tables.
704719
# Note that tables without compression enabled do not respect this flag.
705720
#

src/java/org/apache/cassandra/config/Config.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1287,8 +1287,7 @@ public enum DiskAccessMode
12871287
legacy,
12881288

12891289
/**
1290-
* Direct-I/O is enabled for commitlog disk only.
1291-
* When adding support for direct IO, update {@link org.apache.cassandra.service.StartupChecks#checkKernelBug1057843}
1290+
* When adding support for Direct I/O, update {@link org.apache.cassandra.service.StartupChecks#checkKernelBug1057843}
12921291
*/
12931292
direct
12941293
}

test/conf/latest_diff.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ memtable_allocation_type: offheap_objects
4646

4747
commitlog_disk_access_mode: auto
4848

49+
background_write_disk_access_mode: direct
50+
4951
trickle_fsync: true
5052

5153
sstable:

test/distributed/org/apache/cassandra/distributed/impl/InstanceConfig.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,8 @@ private InstanceConfig(int num,
151151

152152
.set("commitlog_disk_access_mode", "auto")
153153

154+
.set("background_write_disk_access_mode", "direct")
155+
154156
.set("trickle_fsync", "true")
155157

156158
.set("sstable", Map.of(

test/unit/org/apache/cassandra/cql3/CQLTester.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3758,6 +3758,11 @@ protected static void prePrepareServer()
37583758
setupFileSystem();
37593759

37603760
CQLTester.prePrepareServer();
3761+
3762+
// The in-memory (jimfs) filesystem installed above cannot do Direct I/O: its FileStore has no
3763+
// getBlockSize() and it rejects ExtendedOpenOption.DIRECT. cassandra_latest.yaml enables
3764+
// background_write_disk_access_mode: direct, which would otherwise crash every flush+compact here.
3765+
DatabaseDescriptor.setBackgroundWriteDiskAccessMode(Config.DiskAccessMode.standard);
37613766
}
37623767

37633768
protected static void setupFileSystem()

0 commit comments

Comments
 (0)