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

Expose metrics for pending acquire operation latency #178

Merged
merged 3 commits into from
Nov 22, 2023

Conversation

violetagg
Copy link
Member

This is related to reactor/reactor-netty#2946

@violetagg violetagg added the type/enhancement A general enhancement label Nov 16, 2023
@violetagg violetagg added this to the 1.0.4 milestone Nov 16, 2023
@violetagg violetagg requested a review from a team November 16, 2023 13:50
@@ -434,15 +440,22 @@ public void request(long n) {
/**
* Stop the countdown started when calling {@link AbstractPool#doAcquire(Borrower)}.
*/
void stopPendingCountdown() {
void stopPendingCountdown(boolean success) {
if (!timeoutTask.isDisposed()) {
Copy link
Member

Choose a reason for hiding this comment

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

Assuming timeoutTask was disposed, what should happen with the pending metric?

Copy link
Member Author

Choose a reason for hiding this comment

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

Isn't the pending metric per connection pool?

Copy link
Member

Choose a reason for hiding this comment

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

Just trying to understand - so if a borrower was just timed out, its result can be ignored, while the acquisition will actually account for recording the metric. Do I understand it right?

Copy link
Member Author

Choose a reason for hiding this comment

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

!timeoutTask.isDisposed() this check is to ensure that if you invoke this method twice for one and the same Borrower you will not record twice.

Copy link
Member Author

Choose a reason for hiding this comment

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

I mean timeoutTask is disposed here in this method at the end of the method, so we need to guarantee that we record just once.

Copy link
Member Author

@violetagg violetagg Nov 21, 2023

Choose a reason for hiding this comment

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

If the task timed out the recording will happen in run method. Is that what you had in mind?

Copy link
Member

Choose a reason for hiding this comment

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

I now see what is happening. In another comment I expressed my concern about it. Now my question would be - is there no race here? Is the timeoutTask delivered serially with the acquisition or does it run on potentially another thread? In such case, perhaps the flip of the Borrower's AtomicBoolean state would be the trigger to account for either success or failure in the transitioning from pending state?

Copy link
Member

@chemicL chemicL left a comment

Choose a reason for hiding this comment

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

Minor comments / questions, so approving.

@@ -366,7 +366,7 @@ private void drainLoop() {
borrower.fail(new PoolShutdownException());
return;
}
borrower.stopPendingCountdown();
borrower.stopPendingCountdown(true);
Copy link
Member

Choose a reason for hiding this comment

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

This is actually followed by borrower.deliver which calls stopPendingCountdown. Why not rely on the one in deliver then? Is it because of the re-scheduling onto the acquisitionScheduler? Perhaps there should be an abstraction for signalling that pending state is over and what the next step is so that it is encapsulated? It feels unwieldy that the logic is spread over two classes and feels error-prone. Shouldn't this actually cancel the timeout timer instead?

Copy link
Member

@chemicL chemicL left a comment

Choose a reason for hiding this comment

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

Noticed an improvement to make.

@violetagg
Copy link
Member Author

Thank you all for the review!

@violetagg violetagg merged commit 6f350ef into main Nov 22, 2023
1 check passed
@violetagg violetagg deleted the pending-wait-time branch November 22, 2023 13:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants