JavaWebStack / JavaWebStack/orm
Queue.take in SQLPool can produce deadlock
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 7
- Forks
- 1
- PR merge metrics
- No merged PRs in 30d
Description
Describe the Bug
In SQLPool we use take on the queue to wait for a connection to become available. If no connections become available (for example if a single thread is using up all connections) it produces a deadlock causing a lockup of the entire application since all database queries will run into a deadlock
To Reproduce
Steps to reproduce the behavior:
- Set the pool size to 1
- Call get once
- Call get a second time -> gets stuck
Expected behavior
The pool should use poll instead and throw an Exception after a reasonable amount of waiting time preventing a lockup of the entire application
Environment Information:
- Java Language Level 8
- Version 1.0.3
Additional Context
The root cause of this might be a different issue since the pool shouldn't have ran out of connections in the first place. We can check this issue once proper exceptions are thrown.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the SQLPool path that uses Queue.take, then reproduce the issue with pool size 1 by calling get twice. Compare the current blocking behavior with the expected timed wait and exception, and verify that the application no longer remains stuck when no connection becomes available.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100