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
[JBJCA-1445] Avoid deadlock when the connection is being destroyed #791
Open
gazda1983
wants to merge
1
commit into
ironjacamar:main
Choose a base branch
from
gazda1983:JBJCA-1445
base: main
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a doubt here: iiuc if we still have some connections in the cls map but the race condition occurrs this if will not execute and leak would happen anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that is not perfect solution, ideally we would have to have synchronized returnConnection and getConnection but that would be performance issue. When there are more connections in the cls the probability of the issue is much lower and the consequences are smaller. In our case (pool with size 1) the returned connection is always the same which is possibly being retrieved from the pool at the same time. Under such circumstances it happens I would say 1 on 10 activemq restarts. So if we have standard configuratiion for example 20 connections in the pool the issue is unlikelly to happen because connections would be rather different. Event if it would happen the consequence is just one less permit to be acquired. In our case it means zero permits and we cannot connect at all.
Of course I would really appraciate any other solution that would solved the issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's more I cannot just release the lock in case of timeout, because I don't know if the lock is properly acquired, do I ? In case of cls.size = 0 I am sure the lock is invalid because there is no connection which should keep the lock.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gazda1983 tbh, I would prefer to create a general solution for this issue, even if it implies some performance penalty. I have opened #792 which adds a lock for idle connection removal. Would you be able to check if it helps for your case? Alternatively, can you share a reproducer so that I can check it myself?