You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add a remove method to io.vertx.core.net.impl.pool.Lease that allows leaseholders to remove the leased object instead of recycling it to the pool. A client would call remove instead of recycle when they determine the leased object should no longer be used.
The goal is to allow clients of the pool to make deterministic decisions on wether a leased object should be returned or recycled.
Use cases
SqlConnectionPool evictions are now (#1298) tested for idle time and max lifetime. Additionally, the eviction process is periodic and only checks "slots" that are not actively in use. Generally this works fine.
This leaves the problem of pools under heavy load. In this scenario there is no guarantee that eviction will ever be able to check for max lifetime because all connections might be in use when the eviction check is run.
During the SqlConnectionPool.PooledConnection "close" we know if the connection has exceeded its maximum lifetime but there is no way to hold the lease (so it's not recycled) and close/remove the connection from the pool.
With an added remove method, PooledConnection could communicate this removal requirement to the pool as it encounters it.
Contribution
I am willing to implement the feature or pass it off to @tsegismont or @vietj.
The text was updated successfully, but these errors were encountered:
This PR tries to implement eclipse-vertx#4680.
A new method, release(Handler<AsyncResult<T>> handler) is added to the Lease
interface, with the default implementation calling recycle().
In SimpleConnectionPool, LeaseImpl implements the release() method by invoking
slot.pool.release().
The release() method in the Pool reduces slot.usage by 1, and if the usage count
reaches 0, it invokes pool.remove(slot).
The PR also introduces another member variable within the Slot object, called
inactive (boolean). When release() is invoked on a slot, the slot is marked as
inactive irrespective of the usage count. inactive is also set to true in Evict,
before we remove the slot (when usage count is 0).
A new Slot is initialized with inactive as true. The only time inactive gets set
to false is when a connection is successfully established for the slot.
In pool.acquire, we skip slots that are marked as inactive. This behavior means
it is better to invoke pool.connect() whenever a slot is removed, even when
there are no Waiters. This change will be made in a follow-up PR.
release() can subsequently be used by SqlConnectionPool instead of recycle(),
when it determines that a given connection is past its maxLifetime (else it uses
recycle()).
Describe the feature
Add a
remove
method toio.vertx.core.net.impl.pool.Lease
that allows leaseholders to remove the leased object instead of recycling it to the pool. A client would callremove
instead ofrecycle
when they determine the leased object should no longer be used.The goal is to allow clients of the pool to make deterministic decisions on wether a leased object should be returned or recycled.
Use cases
SqlConnectionPool
evictions are now (#1298) tested for idle time and max lifetime. Additionally, the eviction process is periodic and only checks "slots" that are not actively in use. Generally this works fine.This leaves the problem of pools under heavy load. In this scenario there is no guarantee that eviction will ever be able to check for max lifetime because all connections might be in use when the eviction check is run.
During the
SqlConnectionPool.PooledConnection
"close" we know if the connection has exceeded its maximum lifetime but there is no way to hold the lease (so it's not recycled) and close/remove the connection from the pool.With an added
remove
method,PooledConnection
could communicate this removal requirement to the pool as it encounters it.Contribution
I am willing to implement the feature or pass it off to @tsegismont or @vietj.
The text was updated successfully, but these errors were encountered: