CASSANDRA-21085: Fix offset calculation in NativeLibrary.trySkipCache for files > 2GB - #5134
Open
cheeeee wants to merge 1 commit into
Open
CASSANDRA-21085: Fix offset calculation in NativeLibrary.trySkipCache for files > 2GB#5134cheeeee wants to merge 1 commit into
cheeeee wants to merge 1 commit into
Conversation
…(CASSANDRA-21085) In NativeLibrary.trySkipCache(int fd, long offset, long len, String path), the chunking loop across 2GB boundaries decremented offset (offset -= sublen) instead of incrementing it (offset += sublen). On SSTables larger than 2GB, the second and subsequent iterations passed negative offsets to posix_fadvise(..., POSIX_FADV_DONTNEED). This caused: 1. posix_fadvise returning EINVAL (Invalid argument), flooding logs with 'Failed trySkipCache on file: ... Error: Invalid argument'. 2. Failure to evict page cache pages beyond the first 2GB of large SSTables during compaction and sstableupgrade. Additionally, when len == 0, pass the actual offset instead of hardcoding 0. Fixes: CASSANDRA-21085
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Jira Issue
Motivation
In
NativeLibrary.trySkipCache(int fd, long offset, long len, String path), the chunking loop across 2GB boundaries decrementedoffset(offset -= sublen) instead of incrementing it (offset += sublen). On SSTables larger than 2GB, the second and subsequent iterations passed negative offsets toposix_fadvise(..., POSIX_FADV_DONTNEED).This caused:
posix_fadvisereturning-EINVAL(Invalid argument), flooding server logs with:WARN Failed trySkipCache on file: ... Error: Invalid argumentsstableupgrade.Additionally, when
len == 0,trySkipCache(fd, offset, 0, path)was hardcoding0as the offset, ignoring the requested starting offset.Changes
NativeLibrary.trySkipCache:offset += sublen;.len == 0, passoffsetto correctly drop fromoffsetto EOF.testSkipCacheLargeFileinNativeLibraryTestcovering multi-chunk execution across the 2GB boundary.Testing & Kernel eBPF Verification
NativeLibraryTest: 3/3 tests pass.tracepoint:syscalls:sys_enter_fadvise64):offset = 0, len = 2147483647offset = -2147483647, len = 1073741825(negative offset, returnsEINVAL).offset = 0, len = 2147483647offset = 2147483647, len = 1073741825(contiguous positive offset, returns 0).