JavaWebStack / JavaWebStack/orm

Queue.take in SQLPool can produce deadlock

Open
#58 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
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:

  1. Set the pool size to 1
  2. Call get once
  3. 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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.