-
Notifications
You must be signed in to change notification settings - Fork 14.1k
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
KAFKA-7477: Improve Streams close timeout semantics #5747
Conversation
Hello, @vvcephei. Can you take a look? |
Tests passed. @mjsax Can you take a look? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR. We need to preserve existing semantics. I guess, the simplest way will be, to introduce a private synchronized boolean close(final long timeout, final TimeUnit timeUnit, boolean newSemantics)
and call it with true
/false
from new and old close()
. The newSemantics
flag can be passed into waitOnState()
(or we duplicate the old one as waitOnStateBlocking
that we only call for newSemantics==false
?
If there is another more elegant way, we can do it differently, too. Just an idea.
@@ -126,7 +126,7 @@ | |||
public class KafkaStreams { | |||
|
|||
private static final String JMX_PREFIX = "kafka.streams"; | |||
private static final int DEFAULT_CLOSE_TIMEOUT = 0; | |||
private static final int DEFAULT_CLOSE_TIMEOUT = 30; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this change?
We should also add a test |
Hello, @mjsax Looks like a didn't understand initial task properly :)
Please, take a look. |
Failure unrelated. Retest this, please. |
final long begin = time.milliseconds(); | ||
synchronized (stateLock) { | ||
long elapsedMs = 0L; | ||
while (state != targetState) { | ||
if (waitMs == 0) { | ||
if (newSemantics) | ||
return false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: every conditional needs to have braces (per the code style)
not nit: I find this logic a little difficult to follow. Contrary to what @mjsax suggested, wouldn't it be pretty straightforward to map the old semantics on to the new ones like this:
- negative numbers => 0
- 0 => Long.MAX_VALUE
- all other arguments stay the same
?
Then, the old close method could just transform its arguments and call the new method, with no need to have this "new semantics" flag and an early return in the middle of the loop.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vvcephei I like your proposal. Thanks!
Changed PR according to it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the update; this seems easier to follow to me. I had one more question...
streams/src/main/java/org/apache/kafka/streams/KafkaStreams.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for updating the PR. Some more comments.
streams/src/main/java/org/apache/kafka/streams/KafkaStreams.java
Outdated
Show resolved
Hide resolved
streams/src/main/java/org/apache/kafka/streams/KafkaStreams.java
Outdated
Show resolved
Hide resolved
streams/src/main/java/org/apache/kafka/streams/KafkaStreams.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Waiting for second +1 before merging.
Hello @guozhangwang @bbejeck I've got +1 from @mjsax and need one more :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
LGTM! |
Reviewers: Matthias J. Sax <[email protected]>, John Roesler <[email protected]>, Bill Bejeck <[email protected]>, Guozhang Wang <[email protected]>
Merged to |
Reviewers: Matthias J. Sax <[email protected]>, John Roesler <[email protected]>, Bill Bejeck <[email protected]>, Guozhang Wang <[email protected]>
Second part of KIP-358.
This changes based on previous PR discussion.
Default
close
timeout is30 seconds
.Committer Checklist (excluded from commit message)