Skip to content

Pool deadlock: all resources allocated crash#4528

Open
aaravgarg wants to merge 2 commits intomainfrom
fix/ios-crash-pool-deadlock
Open

Pool deadlock: all resources allocated crash#4528
aaravgarg wants to merge 2 commits intomainfrom
fix/ios-crash-pool-deadlock

Conversation

@aaravgarg
Copy link
Collaborator

Summary

  • Increase HTTP connection pool size from 10 to 20 resources
  • Increase pool timeout from 60s to 120s
  • Prevents "TimeoutException: Pool deadlock: all 10 resources have been allocated for 60s" crash under heavy concurrent request load

Crash Stats

Test plan

  • Verify normal HTTP operations still work
  • Stress test with many concurrent API calls

🤖 Generated with Claude Code

Increase pool size from 10 to 20 and timeout from 60s to 120s to reduce
the likelihood of pool exhaustion under heavy concurrent request load.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@aaravgarg aaravgarg requested a review from mdmohsin7 February 1, 2026 23:13
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request aims to resolve a deadlock crash by increasing the HTTP connection pool size and timeout. The change is a direct mitigation for the reported issue. My review focuses on a potential configuration mismatch between the pool size and the underlying HTTP client's maxConnectionsPerHost setting. I've suggested an adjustment to align these values for more predictable behavior and easier debugging of concurrency issues.


_client = IOClient(httpClient);
_pool = Pool(10, timeout: const Duration(seconds: 60));
_pool = Pool(20, timeout: const Duration(seconds: 120));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

While increasing the pool size is a good step towards mitigating the deadlock, there's a configuration mismatch that could lead to subtle issues.

The Pool size is being increased to 20, but the underlying HttpClient is still configured with maxConnectionsPerHost = 15 (on line 19). If all concurrent requests from the pool target the same host, the HttpClient will become the bottleneck, queuing any requests beyond the 15th. This makes the Pool's limit of 20 misleading and can complicate debugging.

For more predictable performance and clearer control over concurrency, these two limits should be aligned. I suggest setting the pool size to 15 to match maxConnectionsPerHost. This still provides a 50% increase in concurrency over the original value of 10.

If a concurrency of 20 is a hard requirement, please consider also increasing maxConnectionsPerHost to 20 in a subsequent change.

Suggested change
_pool = Pool(20, timeout: const Duration(seconds: 120));
_pool = Pool(15, timeout: const Duration(seconds: 120));

Both the HTTP client connection limit and the pool size should match
to avoid the pool allowing more concurrent requests than connections
available.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant