Skip to content

Conversation

@danielcweeks
Copy link
Contributor

This PR depends on #14509 and validates that another commit hasn't moved the kafka offsets that would not be seen by the committer due to the table refreshing during the commit process.

@danielcweeks danielcweeks changed the title Kc snapshot update validation KC snapshot update validation Nov 5, 2025
@danielcweeks danielcweeks force-pushed the kc-snapshot-update-validation branch from a8192c8 to 0b6e560 Compare November 5, 2025 20:06
@aiborodin
Copy link
Contributor

aiborodin commented Nov 6, 2025

Thank you @danielcweeks for the change and @rdblue for the review.

I implemented an alternative API that works in Kafka Connect and reuses most of the existing validation code. It is in the following two PRs:

  1. The suggested new validation API: Implement Snapshot validation API for commits #14514.
  2. The fix for Kafka Connect: Validate parent snapshots in Kafka Connect #14515.

@rdblue @danielcweeks Could you please take a look and let me know what you think?

Copy link
Contributor

@amogh-jahagirdar amogh-jahagirdar left a comment

Choose a reason for hiding this comment

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

Thanks @danielcweeks , think this needs to be rebased but this looks correct to me!

@danielcweeks danielcweeks force-pushed the kc-snapshot-update-validation branch from 1b6145c to c62bd7b Compare November 7, 2025 18:22
@github-actions github-actions bot removed the API label Nov 7, 2025
@danielcweeks danielcweeks changed the title KC snapshot update validation Kafka Connect: validate offsets for refrehsed table state on commit Nov 7, 2025
@danielcweeks danielcweeks changed the title Kafka Connect: validate offsets for refrehsed table state on commit Kafka Connect: validate offsets for refreshed table state on commit Nov 7, 2025
@bryanck
Copy link
Contributor

bryanck commented Nov 7, 2025

LGTM also

@Override
public String errorMessage() {
return String.format(
"Latest offsets do not match expected offsets for this commit. Table: %s, Expected: %s, Last Committed: %s",
Copy link
Contributor

Choose a reason for hiding this comment

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

This is less important in connector code vs core, but I like to have more direct error messages. For example, "Cannot commit to %s, stale offsets:\nExpected: %s\nCommitted: %s"

Copy link
Contributor Author

@danielcweeks danielcweeks Nov 7, 2025

Choose a reason for hiding this comment

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

I'm not sure we can claim the offsets are stale (they may actually be in the future). All we can tell at this point is they don't match and we expect them to.. Nevermind, I think I understand what you mean by stale here.

.set(OFFSETS_SNAPSHOT_PROP, "{\"0\":7}")
.commit();

table.refresh();
Copy link
Contributor

Choose a reason for hiding this comment

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

This isn't needed after the append right? It's the same table instance.

@danielcweeks danielcweeks merged commit 6b28b0e into apache:main Nov 8, 2025
12 checks passed
@danielcweeks
Copy link
Contributor Author

Thanks @rdblue @bryanck @amogh-jahagirdar and @PrabhuJoseph for the reviews!

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants