Skip to content

CASSANDRA-21519: Return CorruptSSTableException if chunk metadata and file size are out of sync#4937

Open
nivykani wants to merge 1 commit into
apache:trunkfrom
nivykani:fill-exception
Open

CASSANDRA-21519: Return CorruptSSTableException if chunk metadata and file size are out of sync#4937
nivykani wants to merge 1 commit into
apache:trunkfrom
nivykani:fill-exception

Conversation

@nivykani

Copy link
Copy Markdown

In ThreadLocalReadAheadBuffer, in the rare case that chunk metadata and file size are out of sync (e.g. bytes erased from the file after chunk metadata is calculated), we’d enter an infinite loop.

The proposed fix is to throw a CorruptSSTableException if we’re trying to read past the end of a file, rather than clamping the read.

The Cassandra Jira

long realPosition = Math.min(channelSize, position);
int blockNo = (int) (realPosition / bufferSize);
if (position >= channelSize)
throw new CorruptSSTableException(null, channel.filePath());

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice find and fix!

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it help with triage to include some details in the exception
"chunk read past EOF: position=<> channelSize=<>"

@tejalchak

Copy link
Copy Markdown

lgtm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants