MaxTotal does not take idle resources into account
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 42/100
Research direction
Start by reproducing the Scala example and tracing KeyPool.Builder, withMaxTotal, and withMaxIdle to find how idle resources are counted. Confirm the fix by rerunning the example and verifying that allocation never exceeds the configured maximum; the final resource count may be a separate issue.
Written by the indexing model from the issue text.
Description
scala> val p = IO.ref(0).flatMap(ref =>
| KeyPool.Builder((i: Int) => Resource.make(ref.update(_ + 1).as(i))(i => IO.println(s"kill $i") *> ref.update(_ - 1)))
| .withMaxTotal(5)
| .withMaxIdle(5)
| .build.use{ keypool =>
| keypool.take(0).replicateA(5).use(_ => ref.get.flatMap(i => IO.println(s"total $i"))) *>
| keypool.take(1).replicateA(5).use(_ => ref.get.flatMap(i => IO.println(s"total $i"))) *>
| IO.println("DONE") *>
| ref.get
| }
| )
val p: cats.effect.IO[Int] = IO(...)
scala> p.unsafeRunSync()
total 5
total 10
kill 1
kill 1
kill 1
kill 1
DONE
kill 0
kill 0
kill 0
kill 0
kill 0
kill 1
val res29: Int = 6
As you can see, at one point 10 resources are allocated, while the max is set to 5. At the end there are still 6 which might be a separate issue...
- Dominant language
- Scala
- Stars
- 39
- Forks
- 18
- Avg merge
- 8h 26m
- Merged PRs (30d)
- 4
Contributor guide
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.
More from typelevel/keypool
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
-
PoolSpec flake Open
Difficulty 3/5 1-2 days Newbie friendliness 35/100
-
commons-pool2 parity
Difficulty 5/5 Over a week Newbie friendliness 25/100
-
commons-pool2 parity
Difficulty 5/5 Over a week Newbie friendliness 25/100
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
All issues in typelevel/keypool
Similar issues
-
Area: Excel support
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
orbeon/orbeon-forms#7893 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
lichess-org/lila#21788 · 2 comments ·
-
area:Iceberg area:writer documentation requires-triage
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
apache/datafusion-comet#6147 ·
-
feature
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
GiganticMinecraft/SeichiAssist#2978 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
chipsalliance/rocket-chip#3833 ·