Skip to content

File descriptor leak under high concurrency #145

@ThePumpingLemma

Description

@ThePumpingLemma

Describe the bug
With our PoC at
https://github.com/kevink-sq/jetty-concurrency-issue-poc/tree/575469b3453e7b09d9d60f6460cdab8117b8e773, we noticed that there is unbounded growth of file descriptors when running our simple load test:

seq 1 15000 | xargs -P1500 -I{} curl --unix-socket ./junix-ingress.sock http://localhost/process

Leading to timeouts from curl and timeout exceptions in jetty:

java.util.concurrent.TimeoutException: Idle timeout expired: 32422/30000 ms
        at org.eclipse.jetty.io.IdleTimeout.checkIdleTimeout(IdleTimeout.java:170)
        at org.eclipse.jetty.io.IdleTimeout.idleCheck(IdleTimeout.java:112)
        at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
        at java.base/java.lang.Thread.run(Thread.java:833)

To Reproduce
Steps to reproduce the behavior (assuming macOS):

  1. Checkout https://github.com/kevink-sq/jetty-concurrency-issue-poc/tree/575469b3453e7b09d9d60f6460cdab8117b8e773
  2. Run mvn compile exec:java -Dexec.mainClass="org.example.Main"
  3. Run seq 1 15000 | xargs -P1500 -I{} curl --unix-socket ./junix-ingress.sock http://localhost/process

Expected behavior
All curl calls should succeed and there should be no timeouts in jetty.

Output/Screenshots
N/A

Please make sure to test the problem still occurs on the latest version of junixsocket
Tested on v2.8.2

Notes
Proposed fix: #144

Metadata

Metadata

Assignees

Labels

bugThe issue describes a bug in the codemergedA fix has been merged to main

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions