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

feat: fail startup if command contains incompatible version #5104

Merged
merged 2 commits into from
Apr 23, 2020

Conversation

agavra
Copy link
Contributor

@agavra agavra commented Apr 17, 2020

Description

fixes #5030 (somewhat)

Introduces a mechanism to fail if we read commands from the command topic that were produced with an incompatible version. The version compatibility matrix is hard-coded in the Command.VersionChecker class.

At the moment, it doesn't fail anything because commands from previous versions won't have a version associated with them.

Testing done

Tested that the framework works with new unit tests
-TODO: when we actually want to leverage this feature, we should make sure that it indeed fails startup. Right now there's no way because all events are accepted :)

Reviewer checklist

  • Ensure docs are updated if necessary. (eg. if a user visible feature is being added or changed).
  • Ensure relevant issues are linked (description should include text like "Fixes #")

@agavra agavra requested a review from a team as a code owner April 17, 2020 19:45
Copy link
Member

@vpapavas vpapavas 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

@big-andy-coates big-andy-coates left a comment

Choose a reason for hiding this comment

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

Hey @agavra, I think this can be simpler...

@VisibleForTesting
static class VersionChecker {

private static final RangeMap<ArtifactVersion, Range<ArtifactVersion>> DB_COMPAT_MATRIX =
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider just a simple monotonically incrementing version, rather than this.

e.g. we start at version 1. (anything without a version is version 0.). When the server starts it checks each command version is the current version, otherwise fails.

As we release a new version of ksql with an incompatibilities we bump the verison. The new version will then reject all older (and newer!) commands.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

that is indeed much simpler - I will go down this path, but I think we need to start with version 0 so that this isn't backwards incompatible unnecessarily

@@ -61,6 +62,7 @@ public void shouldSerializeDeserializeCorrectly() throws IOException {
grep(serialized, ".*\"streamsProperties\" *: *\\{ *\"foo\" *: *\"bar\" *\\}.*");
grep(serialized, ".*\"statement\" *: *\"test statement;\".*");
grep(serialized, ".*\"originalProperties\" *: *\\{ *\"biz\" *: *\"baz\" *\\}.*");
grep(serialized, ".*\"version\" *: *\"" + Version.getVersion() + "\".*");
Copy link
Contributor

Choose a reason for hiding this comment

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

Add test to ensure old json, without version, can be deserialized?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's what the first test does - I suppose what we need is to make sure that the new json can be deserialized properly 😂

@agavra agavra changed the title feat: fail startup if command topic contains incompatible versions feat: fail startup if command contains incompatible version Apr 23, 2020
@agavra agavra merged commit a1751b1 into confluentinc:master Apr 23, 2020
@agavra agavra deleted the compat_check branch April 23, 2020 17:27
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.

Have KSQL server fail on startup after upgrade to incompatible version.
3 participants