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

BoundedAsyncPool object is ready to be manipulated with even though a connection is not created yet #1363

Closed
little-fish opened this issue Jul 27, 2020 · 3 comments
Labels
type: feature A new feature
Milestone

Comments

@little-fish
Copy link

little-fish commented Jul 27, 2020

Feature Request

Is your feature request related to a problem? Please describe

BoundedAsyncPool is ready to be manipulated with even though there is no connection available yet. This causes errors like:

java.util.concurrent.CompletionException: java.util.NoSuchElementException: Pool exhausted
	at java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:331)
	at java.base/java.util.concurrent.CompletableFuture.uniApplyNow(CompletableFuture.java:670)
	at java.base/java.util.concurrent.CompletableFuture.uniApplyStage(CompletableFuture.java:658)
	at java.base/java.util.concurrent.CompletableFuture.thenApply(CompletableFuture.java:2094)
	at io.lettuce.core.support.AsyncConnectionPoolSupport$1.acquire(AsyncConnectionPoolSupport.java:121)

Describe the solution you'd like

Either wait for a connection (min-idle) to be ready upon object pool creation or provide a way to check, whether there are any available connections.


Documentation of the BoundedAsyncPool says:

This object pool allows pre-warming with idle objects upon construction.

I would probably rephrase this sentence to make it clear that it actually requests the idle objects to be created only.

Describe alternatives you've considered

Currently I have to sleep for a fixed amount of ms to work-around this behavior. Which is pretty ugly.

Question

What is the proper way to work-around this behavior?

Thank you.

@little-fish little-fish added the type: feature A new feature label Jul 27, 2020
@mp911de
Copy link
Collaborator

mp911de commented Jul 27, 2020

Thanks for raising the issue. It's indeed an issue that creation completion cannot be awaited. I think we should introduce a new factory method (BoundedAsyncPool.create(…)) that returns a CompletableFuture so pre-warming can be properly synchronized. We also need to reflect this behavior in the documentation.

@mp911de mp911de added this to the 5.3.3 milestone Jul 29, 2020
mp911de added a commit that referenced this issue Jul 29, 2020
BoundedAsyncPool now exposes a create(…) method that returns a CompletionStage that emits the pool once it has finished creation and initialization. The documentation on previously available creation methods reflects that initialization isn't awaited.
mp911de added a commit that referenced this issue Jul 29, 2020
BoundedAsyncPool now exposes a create(…) method that returns a CompletionStage that emits the pool once it has finished creation and initialization. The documentation on previously available creation methods reflects that initialization isn't awaited.
@mp911de
Copy link
Collaborator

mp911de commented Jul 29, 2020

That's in place now.

@mp911de mp911de closed this as completed Jul 29, 2020
@He-Pin
Copy link
Contributor

He-Pin commented Aug 27, 2020

image
Thanks, I will try to update to the new version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature A new feature
Projects
None yet
Development

No branches or pull requests

3 participants