Skip to content

KAFKA-5876: Apply StreamsNotStartedException for Interactive Queries#10597

Merged
ableegoldman merged 4 commits intoapache:trunkfrom
vitojeng:5676-apply-StreamsNotStartedException
May 3, 2021
Merged

KAFKA-5876: Apply StreamsNotStartedException for Interactive Queries#10597
ableegoldman merged 4 commits intoapache:trunkfrom
vitojeng:5676-apply-StreamsNotStartedException

Conversation

@vitojeng
Copy link
Copy Markdown
Contributor

follow-up #8200

KAFKA-5876's PR break into multiple parts, this PR is part 3 - apply StreamsNotStartedException

Committer Checklist (excluded from commit message)

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

@vitojeng
Copy link
Copy Markdown
Contributor Author

vitojeng commented Apr 26, 2021

@ableegoldman Please take a look.

BTW, I encounter a ClassDataAbstractionCoupling check style failure, so I update the checkstyle/suppressions.xml to avoid this failure. If there have a better way to solve this check style failure, please let me know.

@vitojeng vitojeng force-pushed the 5676-apply-StreamsNotStartedException branch from c5f55d5 to 6bce822 Compare April 26, 2021 08:53
Copy link
Copy Markdown
Member

@ableegoldman ableegoldman left a comment

Choose a reason for hiding this comment

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

LGTM, just some suggestions for the wording. Can we add a note to the section in the upgrade-guide that you added for the last exception?

By the way, I wonder if we should also throw this exception for the allMetadata, allMetadataForStore, and queryMetadataForKeymethods? It seems these methods along withKafkaStreams#storeall do the same thing of callingvalidateIsRunningOrRebalancing` which then checks on the KafkaStreams state and throws IllegalStateException if not in one of those two states. Imo all of these would benefit from the StreamsNotStartedException and it doesn't make sense to single that one out.
Thoughts? I know it's not in the KIP but in this case it seems like a trivial improvement that would merit just a quick update on the KIP discussion thread but not a whole new KIP of its own

Comment thread streams/src/main/java/org/apache/kafka/streams/KafkaStreams.java Outdated
Comment thread streams/src/main/java/org/apache/kafka/streams/KafkaStreams.java Outdated
@vitojeng
Copy link
Copy Markdown
Contributor Author

LGTM, just some suggestions for the wording. Can we add a note to the section in the upgrade-guide that you added for the last exception?

Sure, will do. Thank for your reminder.

By the way, I wonder if we should also throw this exception for the allMetadata, allMetadataForStore, and queryMetadataForKeymethods? It seems these methods along withKafkaStreams#storeall do the same thing of callingvalidateIsRunningOrRebalancing` which then checks on the KafkaStreams state and throws IllegalStateException if not in one of those two states. Imo all of these would benefit from the StreamsNotStartedException and it doesn't make sense to single that one out.

One thing may need remind, in the KIP-216, StreamsNotStartedException is sub class of InvalidStateStoreException. That means StreamsNotStartedException is an exception related to the StateStore. It is a bit strange for me if use StreamsNotStartedException to replace IllegalStateException in the validateIsRunningOrRebalancing().

Thoughts? I know it's not in the KIP but in this case it seems like a trivial improvement that would merit just a quick update on the KIP discussion thread but not a whole new KIP of its own

I wonder if it worth to break the API compatibility? The trivial improvement will break the API compatibility(allMetadata(), allMetadataForStore(), queryMetadataForKey). It seems this change means that KIP-216 is no longer API Compatibility and the scope of the KIP will exceed Interactive Query related. WDYT?

@ableegoldman
Copy link
Copy Markdown
Member

It is a bit strange for me if use StreamsNotStartedException to replace IllegalStateException in the validateIsRunningOrRebalancing()

Isn't that what we're doing with the KafkaStreams#store method, though? It also invokes validateIsRunningOrRebalancing() and thus presumably will throw an IllegalStateException if a user invokes this on a KafkaStreams that hasn't been started. Maybe you can run the test you added with the actual changes commented out and see what gets thrown.

I wonder if it worth to break the API compatibility? The trivial improvement will break the API compatibility(allMetadata(), allMetadataForStore(), queryMetadataForKey). It seems this change means that KIP-216 is no longer API Compatibility and the scope of the KIP will exceed Interactive Query related. WDYT?

Those methods are all, ultimately at least, related to Interactive Queries. My understanding is that they would be used to find out where to route a query for a specific key, for example. Plus they do take a particular store as a parameter, thus even InvalidStateStore makes about as much sense for these methods as it does for KafkaStreams#store.

Also just fyi, by sheer coincidence it seems this PR will end up landing in 3.0 which is a major version bump and thus (some) breaking changes are allowed. I think changing up exception handling in this way is acceptable (and as noted above it seems we are already doing so for the #store case, unless I'm missing something). Plus, it seems like compatibility is a bit nuanced in this particular case. Presumably a user will hit this case just because they forgot to call start() before invoking this API, therefore I would expect that any existing apps which are upgraded would already be sure to call start() first and it's only the new applications/new users which are likely to hit this particular exception.

That's my read of the situation, anyway. Thoughts?

@vitojeng
Copy link
Copy Markdown
Contributor Author

vitojeng commented Apr 27, 2021

@ableegoldman
Got it, thank you for the explanation. :)
I am fine with this change. Let me apply StreamsNotStartedException to validateIsRunningOrRebalancing() in this PR, and update the KIP and discussion thread.

@vitojeng vitojeng force-pushed the 5676-apply-StreamsNotStartedException branch from 22ea428 to 1df7b8c Compare April 27, 2021 09:42
@vitojeng
Copy link
Copy Markdown
Contributor Author

@ableegoldman Please take a look. :)
If all work in this PR is completed, I will update the KIP and discussion thread.

@vitojeng vitojeng force-pushed the 5676-apply-StreamsNotStartedException branch from 1df7b8c to 315439b Compare April 27, 2021 09:57
Copy link
Copy Markdown
Member

@ableegoldman ableegoldman left a comment

Choose a reason for hiding this comment

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

Ok I think there's one last thing to discuss, see my other comment. Also just a heads up it looks like there may be some KafkaStreamsTest tests failing on the build

Comment thread docs/streams/upgrade-guide.html Outdated
Comment thread docs/streams/upgrade-guide.html Outdated
Comment thread streams/src/main/java/org/apache/kafka/streams/KafkaStreams.java Outdated
@vitojeng vitojeng force-pushed the 5676-apply-StreamsNotStartedException branch from 315439b to b843e78 Compare April 29, 2021 01:49
@vitojeng
Copy link
Copy Markdown
Contributor Author

@ableegoldman Please take a look. :)

@ableegoldman
Copy link
Copy Markdown
Member

Thanks @vitojeng -- just to clarify, I was proposing that we do throw the StreamsNotStartedException for the #allMetadata, #allMetadataForStore, and #queryMetadataForKey methods in addition to just #store. Imo if we do this for #store, we should do it for all of these which have similar behavior and effect -- for example at the moment, all of these invoke validateRunningOrRebalance and thus would all throw IllegalStateException if the Streams has not been started. It seems odd to add this exception which perfectly addresses this specific case, and then only apply it to that one method.
What I was saying we should not do was to throw StreamsNotStartedException for any state that isn't RUNNING or REBALANCING. In other words we still only throw it for CREATED, but we throw the same exception across the board. Basically any method that currently invokes validateRunningOrRebalancing (which is #store + the ones listed above, I believe there are 5 methods in total)

Thoughts?

@vitojeng
Copy link
Copy Markdown
Contributor Author

Oh, I get your point. This make sense and totally agree. Thanks @ableegoldman for explanation.

@vitojeng vitojeng force-pushed the 5676-apply-StreamsNotStartedException branch from b843e78 to a090ee3 Compare April 30, 2021 08:16
Comment thread streams/src/main/java/org/apache/kafka/streams/KafkaStreams.java Outdated
Copy link
Copy Markdown
Member

@ableegoldman ableegoldman left a comment

Choose a reason for hiding this comment

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

Looking good! Just one suggestion about the wording in the exception message but after that I think we can merge

Vito Jeng and others added 2 commits May 1, 2021 05:39
Co-authored-by: A. Sophie Blee-Goldman <ableegoldman@gmail.com>
@vitojeng
Copy link
Copy Markdown
Contributor Author

vitojeng commented May 3, 2021

@ableegoldman Please take a look. :)

@ableegoldman
Copy link
Copy Markdown
Member

LGTM. Seems to be some unrelated known-flaky tests (RaftClusterTest and some Connect test), but also a unit test failure in RocksDBStore which I've never seen before. It's pretty suspicious since it's just a unit test and doesn't have any timeouts, setup, etc that might make it flaky. But it's hard to imagine that this PR could have caused that, and it did pass on the other two builds so I don't think it's related and will merge to trunk. But let's keep an eye on that (KAFKA-12747)

@ableegoldman ableegoldman merged commit 816f5c3 into apache:trunk May 3, 2021
@ableegoldman
Copy link
Copy Markdown
Member

Ah, looks like that test just assumes no two UUIDs will have the same prefix. Fair assumption that no two UUIDs will be the same, but I guess that doesn't hold up if you cut off some of those digits. Anyways just following up on that, should be easy to fix

@vitojeng vitojeng deleted the 5676-apply-StreamsNotStartedException branch May 4, 2021 01: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.

2 participants