Skip to content

Add maximumPendingConnections property for load-shedding#2387

Open
vlsi wants to merge 1 commit intobrettwooldridge:devfrom
vlsi:feature/maximum-pending-connections
Open

Add maximumPendingConnections property for load-shedding#2387
vlsi wants to merge 1 commit intobrettwooldridge:devfrom
vlsi:feature/maximum-pending-connections

Conversation

@vlsi
Copy link

@vlsi vlsi commented Feb 14, 2026

Under traffic spikes or database outages, threads can accumulate unboundedly waiting for pool connections, then fail in a thundering herd after connectionTimeout. This adds an opt-in admission control that rejects getConnection() calls immediately when too many threads are already waiting, preventing waiter buildup and reducing the blast radius of pool exhaustion.

The property defaults to 0 (unlimited) for full backward compatibility.

Fixes #580

Under traffic spikes or database outages, threads can accumulate
unboundedly waiting for pool connections, then fail in a thundering
herd after connectionTimeout. This adds an opt-in admission control
that rejects getConnection() calls immediately when too many threads
are already waiting, preventing waiter buildup and reducing the blast
radius of pool exhaustion.

The property defaults to 0 (unlimited) for full backward compatibility.

Refs: brettwooldridge#580

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@vlsi vlsi force-pushed the feature/maximum-pending-connections branch from 36f74d9 to 553029a Compare February 14, 2026 19:47
super(config);

this.connectionBag = new ConcurrentBag<>(this);
this.connectionBag = new ConcurrentBag<>(this, config.getMaximumPendingConnections());
Copy link
Author

@vlsi vlsi Feb 14, 2026

Choose a reason for hiding this comment

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

The drawback of passing getMaximumPendingConnections is that ConcurrentBag won't react to the changes of maximumPendingConnections.

An alternative options could be:
a) Pass HikariConfig to ConcurrentBag
b) Add interface ConcurrentBagConfig { int getMaximumWaiters(); int getMaximumObjects();} so the bag could query the required limits

Any thoughts?

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.

Limit pending connection queue size

1 participant