-
Notifications
You must be signed in to change notification settings - Fork 55
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
Connection not released when request is cancelled #144
Comments
Searching in: #143 The behavior is the same, connection not released after cancellation. I just need to bump the numbers of executions from 5 to 10 to achieve the same result. I have also tested it against the new 0.8.8 version and the problems still occurs. But it seems more simple to reproduce with the following code presented on the repository above |
I was looking over the implmentation of the connection pool The PoolBuilder have a method to register a releaseHandler, is it possible to force implementation of a release method in SPI Connection interface? This way PostgresqlConnection in r2dbc-postgresql will need to have a release mechanism and it could be registered on the pool creation. I have tried using commitTransaction as release handler and it seems that the connection gets released, but not always a commit will be the best approach to release the connection. |
You can register a customizer through I'm still wondering about the cause. If you can reliably reproduce the issue, then I would like to ask you to either register a |
@DenisMd 0.9 updates to the new R2DBC spec, it's not a rewrite of the pool or the like. |
I was able to reproduce the leaks too.
Normally log for 1 standalone request
Then i launched jmeter load-scenario(100 hundred requests in parallel and 3.5 sec timeout for response). After completion a prometheus-metric was: and never go down build.config
|
Interesting case, if i execute sql-request in a transaction there will be no leaks
|
Thanks for your reproducers. I'm finally able to reproduce the issue although it requires multiple attempts. Trying to figure out what's happening and where connections get lost. |
[#144] Signed-off-by: Mark Paluch <[email protected]>
[#144] Signed-off-by: Mark Paluch <[email protected]>
Refining the allocation and cancellation guards indeed helped to reduce (fixed?) the test runs in which connections were lost in the connection pool. While tracing code paths that might skip connection release, I found that |
I reported the issue back to the Reactor team to get their input. |
@mp911de We could reproduce the issue even with the recent changes on r2dbc pool. But we agree that somehow the problem may be on the reactor implementation. Will investigate it on our side, any new discovery will be posted here. |
@mp911de
and with this all connections was released ... but we dont if this is the better solution |
Please note that we cannot treat the problem as solved unless the leak in |
This approach seems an idea the connections stop beeing stucked, but i'm not sure if it closes the connection prematurely.
Eventhough the behaviour seems correct the unit tests show that somehow the connection is beeing closed when it should still be open. @mp911de do you have any concerns about that? I would like to hear your opinion on that matter. This is not a final solution but could be a workaround while the reactor problem is not solved
|
Is this |
Commenting for increased visibility - looks like the If you can reproduce the issue locally, confirmation that the fix works is desired. See reactor/reactor-core#2836 (comment) . |
The change done in the reactor core seems to fix this issue. However when running a lot of simultaneous requests (50k+) an error shows up
I guess that it is just a limitation of a single instance processing a lot of requests to try to simulate the lock behavior, in a real application this requests will be shared with multilple instances and this queue limit will be enough, am i right? There are some concerns we should address on this queue limitation? |
@rogtejada Have you published a snapshot? We would like to test it in our project. |
@figroc No. An issue was opened on project-reactor (reactor/reactor-core#2836) where a solution was proposed in this PR (reactor/reactor-core#2859). I have just build this branch locally and used this artifact to run my tests |
I can confirm that upgrading to Reactor Core 3.4.14 snapshots fixes the issue. |
Bug Report
Versions
Current Behavior
This issue was first opened on r2dbc-postgresql, some discussion can be seen there
pgjdbc/r2dbc-postgresql#459
Then it was opened here:
#140
The result was a fix on the pool but it does not fix the problem.
We have created a new project without spring dependencies and the connection keeps getting stucked.
You can find the source code here: https://github.com/jfrossetto/r2dbc-stress-cancel
LOGFILE: https://github.com/jfrossetto/r2dbc-stress-cancel/blob/master/log_stresscancel.txt
There was another issue opened with the same problem here: #143
Stack trace
Table schema
Input Code
-- your SQL here;
Steps to reproduce
Input Code
// your code here;
Expected behavior/code
Possible Solution
Additional context
The text was updated successfully, but these errors were encountered: