pool: fix idle_conns assertion in test_pool_close#24932
Merged
Conversation
|
Connected to Huly®: V_0.6-23401 |
b2ba188 to
35339c0
Compare
spytheman
approved these changes
Jul 20, 2025
spytheman
left a comment
Contributor
There was a problem hiding this comment.
Excellent analysis.
Thank you 🙇🏻♂️ .
This file contains hidden or 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
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.
I noticed that test_pool_close() would sometimes fail, but not all the time. On line 224, sometimes there would be 5 entries in idle_conns and sometimes 6. After reviewing the code in vlib/pool/connection.v, if prune_connections() runs between the calls to
c := p.get()andp.put(c), which can happen, then an additional conn will get allocated because the number of idle conns has dropped below the min_idle_conns value of 5.I printed out some intermediate values in the test and captured the following when the test failed.
immediately after this statement, I extracted the following values:
After the next 2 statements execute:
I extracted out the following values:
This tells me that after the call to get a connection from the pool, and before the call to put the connection back in, prune_connections() ran in the background. We can see that the last idle connection was returned by get() and its usage count was incremented. Then another connection was allocated to bring the number of idle connections back up to 5. Finally, the connection returned by get() was put back into the pool.
So, it looks to me that the proper assertion should be
>=instead of==.