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

Reset pending gauge on handler unregistered #98

Merged
merged 3 commits into from
Feb 24, 2020
Merged

Conversation

jotak
Copy link
Contributor

@jotak jotak commented Feb 18, 2020

Mirroring behaviour in HandlerRegistration
Fixes #95

Mirroring behaviour in HandlerRegistration
Fixes vert-x3#95
@jotak
Copy link
Contributor Author

jotak commented Feb 18, 2020

Now I don't know if this needs to be cherry-picked to master ... as it seems in master vertx-core we are not discarding the pending events on unregister? (or maybe it's still done but in a different place, I couldn't find that)

Copy link
Contributor

@tsegismont tsegismont left a comment

Choose a reason for hiding this comment

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

Can you add a test for this @jotak ? I believe this is the right thing to do.

@tsegismont
Copy link
Contributor

@jotak would you mind to check if there's a similar issue with the Dropwizard implementation? Thank you

@jotak
Copy link
Contributor Author

jotak commented Feb 19, 2020

@tsegismont
About dropwizard, I believe there's nothing to do: see https://github.com/vert-x3/vertx-dropwizard-metrics/blob/master/src/main/java/io/vertx/ext/dropwizard/impl/EventBusMetricsImpl.java#L251-L253
Pending gauges are already updated on unregistering.

About adding a test: I struggle to make something reproducible about pending messages. I can easily check that after unregistration there's no pending message, but that wouldn't prove anything about what we do here. Do you have any suggestion?

@tsegismont
Copy link
Contributor

tsegismont commented Feb 19, 2020 via email

if (first.getAndSet(false)) {
step2FirstReceived.complete();
}
step3BlockWorker.await();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tsegismont I did more or less as you suggested, with a difference: event consuming is blocked on the event loop and not on worker thread. I know it can be a bit risky on a slower environment - here it works on my machine (let's see what CI says).

I tried with a worker thread as well, using:

WorkerExecutor executor = vertx.createSharedWorkerExecutor("my-worker-pool", 1);
 // then in consumer handler:
executor.executeBlocking(promise -> { /*block*/... });

But it doesn't work, as this is not blocking thequeue processing (pending count is decreased despite blocking, here).

Or is there another way to do, such as telling vertx to use my worker for EB queue processing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, I think I understand how to do: now using .setWorker(true).setWorkerPoolSize(1) on my deployment options... is that what you expected?

Copy link
Contributor

Choose a reason for hiding this comment

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

It doesn't work without .setWorkerPoolSize(1) ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It does ... i thought it would be necessary to have the other events blocked, but it's not. I removed it.

Copy link
Contributor

@tsegismont tsegismont left a comment

Choose a reason for hiding this comment

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

LGTM, good job @jotak !

@jotak
Copy link
Contributor Author

jotak commented Feb 24, 2020

thanks @tsegismont , i'll cherry-pick to 3.9 and 4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants