Repository navigation
Reuse one LDAP connection per thread for searches - #91
Merged
Merged
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
LDAP connections can leak after bind exceptions and worker termination, while the new search path also omits expected debug logs and obscures some bind failures.
4 open issues
What changed in this PR
Reduces LDAP search overhead by reusing one bound connection per thread, while leaving write behavior unchanged.
Changes:
- Cache search connections per thread and reconnect once when a reused connection fails.
- Update unit tests for connection reuse, thread isolation, reconnection, and bind failures.
- Bump the application version to
1.2.12.
| File | Description |
|---|---|
spec/unit/entitlements/service/ldap_spec.rb |
Updates search stubs and adds connection-reuse and failure scenarios. |
lib/version.rb |
Sets version to 1.2.12. |
lib/entitlements/service/ldap.rb |
Adds per-thread search connections, reconnection handling, and shared LDAP options. |
Gemfile.lock |
Synchronizes the locked application version. |
Review effort: Max (auto)
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
northrup
approved these changes
Nov 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Version bump to 1.2.12.
Each
searchopened a new TLS connection and bound before running. Searches now keep one bound connection per thread and reuse it. Writes are unchanged.If a reused connection fails (for example the server closed it while idle), it is closed and the search retries once on a new connection. The existing retries for DNS and timeout failures still apply.
In an entitlements CI run with an equivalent patch, 412 searches used 7 connections instead of 412, and the prefetch phase dropped from 38.6s to 22.1s.
Tests:
bundle exec rspec spec/unitpasses (572 examples, 0 failures, 100% coverage).bundle exec rubocopis clean.