-
Notifications
You must be signed in to change notification settings - Fork 23
CASSANALYTICS-124: Commitlog reading not progressing in CDC due to incorrect CommitLogReader.isFullyRead #176
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -284,6 +284,9 @@ private void readCommitLogSegment() throws IOException | |
| { | ||
| stats.commitLogBytesSkippedOnRead(startMarker.position() - reader.getFilePointer()); | ||
| segmentReader.seek(startMarker.position()); | ||
| // When starting from an offset, position must be initialized to startMarker.position() | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just leaving a note so we're aligned (no change requested). The relationship between reader, startMarker, and this.position is something we should consider structurally relating in the future. If there's an expectation that these numeric sentinels are linked, wrapping them in code that enforces those invariants would help prevent gaps and allow us to refactor more safely. Again - nothing to do here. ;) Just my first thoughts on looking at this code in detail. I think this is worth considering for a broader refactor; this BufferingCommitLogReader seems like a leaky abstraction on top of the regular commit log reader that's forcing us to do a lot of heavy lifting and exposing us to a lot of potential pain if we change it too much. 😬
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree, we can note this down and do the refactoring in another patch later. |
||
| // rather than 0; an incorrect value causes isFullyRead to fail. | ||
| this.position = startMarker.position(); | ||
| } | ||
|
|
||
| for (CommitLogSegmentReader.SyncSegment syncSegment : segmentReader) | ||
|
|
@@ -309,6 +312,13 @@ private void readCommitLogSegment() throws IOException | |
| break; | ||
| } | ||
| } | ||
|
|
||
| // If the segment reader iterator completes reading commitlog with padded zeros, set the position | ||
| // as maxOffset to mark completion of reading commitlog | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This comment confused me a bit and sent me down a rabbit hole. wdyt about this instead? Is it accurate? |
||
| if (statusTracker.shouldContinue()) | ||
| { | ||
| this.position = (int) log.maxOffset(); | ||
| } | ||
| } | ||
| // Unfortunately CommitLogSegmentReader.SegmentIterator (for-loop) cannot throw a checked exception, | ||
| // so we check to see if a RuntimeException is wrapping an IOException. | ||
|
|
@@ -427,6 +437,7 @@ private void readSection(FileDataInput reader, | |
| if (serializedSize == LEGACY_END_OF_SEGMENT_MARKER) | ||
| { | ||
| logger.trace("Encountered end of segment marker at", "position", reader.getFilePointer()); | ||
| this.position = (int) log.maxOffset(); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we have a unit test that exercises this case of "hit |
||
| statusTracker.requestTermination(); | ||
| return; | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excepting the
assertThat(result.updates()).isEmpty();check, this test is identical totestPositionAtMaxOffsetInCommitlogsWithPaddedZeros(). Maybe we keep this one and just leave a javadoc breadcrumb to the JIRA ticket here and the 2 cases this test covers?