Skip to content
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

DBZ-8087 Get previous vgtid from vgtid key in offsets #204

Merged
merged 2 commits into from
Jul 30, 2024

Conversation

twthorn
Copy link
Contributor

@twthorn twthorn commented Jul 22, 2024

It is non-deterministic/race condition whether or not the OFFSET_TRANSACTION_ID is present in the offsets (if we happen to store offsets during a transaction, it is added since it's not null, otherwise it is not added). For example if heartbeats are enabled, there is not transaction but we still commit offsets.

Epoch needs to be based on the vgtid we store as for the VGTID_KEY since that is always present in offsets regardless of whether we are in a transaction or not. This fixes an edge case where we saw epoch being set back down to zero because we were getting null for our previous VGTID string. Also fail loudly if we ever see this case again (null previous VGTID but there is state for the epoch, this is invalid state and should throw exception).

Copy link
Contributor

@HenryCaiHaiying HenryCaiHaiying left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link
Contributor

@jpechane jpechane left a comment

Choose a reason for hiding this comment

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

@twthorn LGTM, thanks! I left just a minor comment around code structure.

}
}

public Long getEpoch(String shard, String previousVgtidString, String vgtidString) {
if (previousVgtidString == null) {
if (previousVgtidString == null && shardToEpoch.get(shard) != null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this could be collapse into

 if (previousVgtidString == null) {
    if (shardToEpoch.get(shard) != null)

@twthorn twthorn requested a review from jpechane July 26, 2024 15:25
@twthorn
Copy link
Contributor Author

twthorn commented Jul 29, 2024

@jpechane this is ready for re-review, thanks!

@jpechane jpechane merged commit 2747378 into debezium:main Jul 30, 2024
3 checks passed
@jpechane
Copy link
Contributor

@twthorn Applied, thanks!

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.

3 participants