Skip to content

Reuse one LDAP connection per thread for searches - #91

Merged
Ayomi-gh merged 3 commits into
mainfrom
ayomi-gh/ldap-connection-reuse
Nov 10, 2026
Merged

Ayomi-gh merged 3 commits into
mainfrom
ayomi-gh/ldap-connection-reuse

Conversation

@Ayomi-gh

@Ayomi-gh Ayomi-gh commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Version bump to 1.2.12.

Each search opened 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/unit passes (572 examples, 0 failures, 100% coverage). bundle exec rubocop is clean.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI adaptive review requested due to automatic review settings November 6, 2026 16:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 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)

Comment thread lib/entitlements/service/ldap.rb Resolved
Comment thread lib/entitlements/service/ldap.rb Resolved
Comment thread lib/entitlements/service/ldap.rb Resolved
Comment thread lib/entitlements/service/ldap.rb Resolved
Ayomi-gh and others added 2 commits November 6, 2026 18:08
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@Ayomi-gh
Ayomi-gh merged commit f104bee into main Nov 10, 2026
20 checks passed
@Ayomi-gh
Ayomi-gh deleted the ayomi-gh/ldap-connection-reuse branch November 10, 2026 14:59
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.

3 participants