Skip to content

MINOR: Refactor high watermark access and validation#7055

Merged
hachikuji merged 2 commits intoapache:trunkfrom
hachikuji:minor-refactor-high-watermark-access
Jul 11, 2019
Merged

MINOR: Refactor high watermark access and validation#7055
hachikuji merged 2 commits intoapache:trunkfrom
hachikuji:minor-refactor-high-watermark-access

Conversation

@hachikuji
Copy link
Copy Markdown
Contributor

The purpose of this patch is to restrict the paths for updating and accessing the high watermark and the last stable offset. By doing so, we can validate that these offsets always remain within the range of the log. We also ensure that we never expose LogOffsetMetadata unless it is fully materialized. Finally, this patch makes a few naming changes. In particular, we remove the highWatermark_= and highWatermarkMetadata_= which are both misleading and cumbersome to test.

Committer Checklist (excluded from commit message)

  • Verify design and implementation
  • Verify test coverage and CI build status
  • Verify documentation (including upgrade notes)

Copy link
Copy Markdown
Member

@mumrah mumrah left a comment

Choose a reason for hiding this comment

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

LGTM 👍

else
hw
updateHighWatermarkMetadata(LogOffsetMetadata(newHighWatermark))
newHighWatermark
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should we return the long value only or the whole LogOffsetMetadata?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We could, but I was trying to avoid exposing LogOffsetMetadata unless we were willing to materialize it.

* @param hw the suggested new value for the high watermark
* @return the updated high watermark offset
*/
def updateHighWatermark(hw: Long): Long = {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should this be named initializeHighWatermark maybe?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I called it update since it is also used in the fetcher when updating the high watermark after a fetch response.

@hachikuji
Copy link
Copy Markdown
Contributor Author

retest this please

@hachikuji hachikuji merged commit 7a7d4cb into apache:trunk Jul 11, 2019
bfncs pushed a commit to bfncs/kafka that referenced this pull request Jul 12, 2019
The purpose of this patch is to restrict the paths for updating and accessing the high watermark and the last stable offset. By doing so, we can validate that these offsets always remain within the range of the log. We also ensure that we never expose `LogOffsetMetadata` unless it is fully materialized. Finally, this patch makes a few naming changes. In particular, we remove the `highWatermark_=` and `highWatermarkMetadata_=` which are both misleading and cumbersome to test.

Reviewers: David Arthur <mumrah@gmail.com>
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