aweisberg commented on code in PR #4178: URL: https://github.com/apache/cassandra/pull/4178#discussion_r2116397938
########## src/java/org/apache/cassandra/io/util/ChannelProxy.java: ########## @@ -40,30 +42,55 @@ */ public final class ChannelProxy extends SharedCloseableImpl { + + public enum IOMode + { + BUFFERED, + DIRECT + } + private final File file; private final String filePath; private final FileChannel channel; - public static FileChannel openChannel(File file) + public static FileChannel openChannel(File file, OpenOption... openOptions) { try { - return FileChannel.open(file.toPath(), StandardOpenOption.READ); + return FileChannel.open(file.toPath(), openOptions); } catch (IOException e) { throw new RuntimeException(e); } } + private static OpenOption[] openOptions(IOMode ioMode) + { + switch (ioMode) + { + case DIRECT: + return new OpenOption[]{ StandardOpenOption.READ, ExtendedOpenOption.DIRECT }; Review Comment: Uh... the commit log is not safe as currently written. It writes to the file, but doesn't sync the metadata on flush. That means the commit log may claim it has flushed the data, but the filesystem journal has not been flushed so the file length will be wrong and could truncate the file on restart. Additionally Direct IO doesn't actually make data durable on disk (emit write barriers) it just flushes it to the cache of the disk. If your disk cache is volatile then you can lose data. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: pr-unsubscr...@cassandra.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: pr-unsubscr...@cassandra.apache.org For additional commands, e-mail: pr-h...@cassandra.apache.org