-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Support customizing BlockedThreadChecker #4283
Merged
vietj
merged 1 commit into
eclipse-vertx:master
from
dano:blocked-thread-checker-factory
Mar 2, 2022
Merged
Support customizing BlockedThreadChecker #4283
vietj
merged 1 commit into
eclipse-vertx:master
from
dano:blocked-thread-checker-factory
Mar 2, 2022
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bf4fe5a
to
5faf826
Compare
vietj
reviewed
Feb 23, 2022
vietj
reviewed
Feb 23, 2022
the |
you can call `disableThreadChecks()` to disable thread checks
…On Wed, Feb 23, 2022 at 2:55 PM dano ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In src/test/java/io/vertx/core/BlockedThreadCheckerTest.java
<#4283 (comment)>:
> + VertxOptions vertxOptions = new VertxOptions();
+ vertxOptions.setMaxWorkerExecuteTime(maxWorkerExecuteTime);
+ vertxOptions.setMaxWorkerExecuteTimeUnit(maxWorkerExecuteTimeUnit);
+ vertxOptions.setWarningExceptionTime(warningExceptionTime);
+ vertxOptions.setWarningExceptionTimeUnit(warningExceptionTimeUnit);
+ Vertx newVertx = vertx(vertxOptions);
+ ((VertxInternal) newVertx).blockedThreadChecker().setThreadBlockedHandler(bte -> {
+ Assert.assertEquals(NANOSECONDS.convert(maxWorkerExecuteTime, maxWorkerExecuteTimeUnit), bte.maxExecTime);
+ Assert.assertEquals(NANOSECONDS.convert(warningExceptionTime, warningExceptionTimeUnit), bte.warningExceptionTime);
+ cl.countDown();
+ });
+ DeploymentOptions deploymentOptions = new DeploymentOptions();
+ deploymentOptions.setWorker(true);
+ newVertx.deployVerticle(verticle, deploymentOptions);
+ await();
+ awaitLatch(cl);
@vietj <https://github.com/vietj> I tried to do it this way initially,
but the testComplete() and assert* methods provided by the base class
have checks to make sure they are called from an event loop thread, which
means the test fails when they get called from the BlockedThreadChecker
thread.
I could use runOnContext to get back on an event loop thread inside of
the threadBlockedHandler, though. Do you prefer that to using the
CountdownLatch?
—
Reply to this email directly, view it on GitHub
<#4283 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AABXDCRHSJK4IGJM3EJON43U4TRNRANCNFSM5O7I63LQ>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
476e838
to
4c8ffe3
Compare
vietj
reviewed
Feb 24, 2022
vietj
requested changes
Feb 24, 2022
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.
minor change on BlockedThreadEvent
and we are good to go
Signed-off-by: Dan O'Reilly <oreilldf@gmail.com>
4c8ffe3
to
13e9571
Compare
thanks for the contribution @dano |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Signed-off-by: Dan O'Reilly oreilldf@gmail.com
Adds support for customizing the implementation of BlockedThreadChecker, exposing an API that allows users to pass a callback that will be executed whenever a thread is blocked for longer than the allowed duration. To use the API, users have to call the
blockedThreadChecker()
getter onVertxInternal
.Motivation:
In my application, I want to be able to restart the JVM if thread stay blocked for an extended period of time, so that my application can potentially self-heal if something goes very wrong and a thread ends up stuck forever. It's currently not possible to do this (at least as far as I can tell). Adding this new API makes it possible.