-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Wait for the async broker port listener close operations to complete at shutdown #9308
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
Conversation
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BrokerService.java
Outdated
Show resolved
Hide resolved
eolivelli
left a comment
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
|
/pulsarbot run-failure-checks |
3 similar comments
|
/pulsarbot run-failure-checks |
|
/pulsarbot run-failure-checks |
|
/pulsarbot run-failure-checks |
pulsar-broker-common/src/main/java/org/apache/pulsar/broker/ServiceConfiguration.java
Outdated
Show resolved
Hide resolved
f43e286 to
0714b29
Compare
|
@merlimat I have revisited the solution by adding closeAsync methods so that it's possible to wait for shutdown using the existing |
pulsar-broker/src/main/java/org/apache/pulsar/broker/PulsarService.java
Outdated
Show resolved
Hide resolved
|
/pulsarbot run-failure-checks |
pulsar-broker/src/main/java/org/apache/pulsar/broker/MessagingServiceShutdownHook.java
Show resolved
Hide resolved
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BrokerService.java
Outdated
Show resolved
Hide resolved
0714b29 to
2faceb6
Compare
|
@eolivelli I have made the change to closeAsync so that it doesn't throw checked exceptions. I took another look at MessagingServiceShutdownHook logic and unfortunately I didn't find a way to simplify the logic. There the intention is to run the shutdown in a background thread so that the actual shutdown can continue if the shutdown takes longer than the timeout. Although the code might look bad, there isn't a real alternative. Catching Exceptions is necessary to catch also possible runtime exceptions that could happen at shutdown. You can try to suggest a better way, I tried and simply didn't find one. :) |
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BrokerService.java
Outdated
Show resolved
Hide resolved
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BrokerService.java
Outdated
Show resolved
Hide resolved
pulsar-broker/src/main/java/org/apache/pulsar/broker/PulsarService.java
Outdated
Show resolved
Hide resolved
|
/pulsarbot run-failure-checks |
3 similar comments
|
/pulsarbot run-failure-checks |
|
/pulsarbot run-failure-checks |
|
/pulsarbot run-failure-checks |
|
/pulsarbot run-failure-checks |
- add BrokerService.closeAsync and PulsarService.closeAsync so that shutdown can handle asynchronous closing operations
- address review comment
2faceb6 to
81b5945
Compare
eolivelli
left a comment
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.
looks great to me
|
/pulsarbot run-failure-checks |
|
@merlimat Please review this PR since it has changed since you approved it. |
merlimat
left a comment
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.
Looks good. Just a couple of comments
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BrokerService.java
Outdated
Show resolved
Hide resolved
pulsar-broker/src/main/java/org/apache/pulsar/broker/PulsarService.java
Outdated
Show resolved
Hide resolved
Catching RuntimeExceptions isn't sufficient since checked exceptions can be thrown in the JVM with solutions like "sneaky throws" This reverts commit 01b5f6f.
eolivelli
left a comment
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.
Still good for me
|
/pulsarbot run-failure-checks |
merlimat
left a comment
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.
👍
|
@sijie @merlimat I have continued the work started in this PR in another PR . Please review #10199 since it will also help improve CI stability when the asynchronous tasks of broker shutdown can be controlled in tests. This prevents problems which are caused by too many brokers being active at the same time. This could currently happen when previous brokers are asynchronously shutting down. |
Motivation
The main motivation for making this change to shut down port listeners synchronously in
BrokerService.closeis to reduce test flakiness.While investigating the flaky test MessageIdTest, these type of exceptions were seen in logs:
It seems that this problem could occur when the test code is able to access the broker instance that is already terminated.
Modifications
To understand the modifications:
The original solution was to wait up to 10 seconds until the port listeners were closed.
A change was requested to add a new setting for this. After adding this, another change was requested to combine these operations in a way that the existing
brokerShutdownTimeoutMssetting would also apply to the closing of the port listeners.This solution for this adds BrokerService.closeAsync and PulsarService.closeAsync methods so that it's possible to combine the closing of the ports to the close operation that uses
brokerShutdownTimeoutMssetting.