Release and reuse the clients held by ClientManager - #2853
Conversation
Hello francoisferrand,My role is to assist you with the merge of this Available options
Available commands
Status report is not available. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files
... and 2 files with indirect coverage changes
@@ Coverage Diff @@
## development/9.6 #2853 +/- ##
===================================================
+ Coverage 76.50% 76.60% +0.09%
===================================================
Files 206 206
Lines 14427 14450 +23
===================================================
+ Hits 11038 11069 +31
+ Misses 3379 3371 -8
Partials 10 10
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
98e06df to
4378d82
Compare
4378d82 to
5adc856
Compare
Waiting for approvalThe following approvals are needed before I can proceed with the merge:
|
The interval sweeping inactive credentials was started and never stopped: it kept the event loop alive, so a process could not exit on its own, and it kept the whole ClientManager reachable along with its keepAlive agents and client caches. The lifecycle processors meant to clear it, but did so on themselves rather than on the ClientManager, which never had anything to clear it with. Give the class a close() and call it from the services owning a manager, once their consumers and producers are done with the clients. Issue: BB-877
A queue processor built a new ClientManager for every entry it replicated, and another one each time a retry moved to the next host. Each of them was left behind with its credentials cache, its keepAlive agents and the sweep timer holding it, so a role was assumed again for every single object. Hold them on the queue processor, keyed by destination host and role, the way the copy location tasks already share theirs, and release them on shutdown. They assume their role on the destination STS, so they cannot share the cache the copy location tasks read their sources with. Issue: BB-877
The spec ended up with two adjacent describe('stop') blocks, one left by
the redis subscriber teardown and one by the client manager teardown, so
mocha reported the shutdown tests under two identically titled sections.
Keep a single suite holding all four of them, which is what the output is
expected to show for a class with one stop().
Issue: BB-877
f055adc to
3a2229b
Compare
|
/approve |
|
I have successfully merged the changeset of this pull request
The following branches have NOT changed:
This pull request did not target the following hotfix branch(es) so they
Please check the status of the associated issue BB-877. Goodbye francoisferrand. The following options are set: approve |
ClientManagerstarts a 30 min interval to sweep inactive credentials, keeps the handle, and never uses it again. Nothing clears it and the timer is notunref'd, so a process cannot exit on its own. The lifecycle processors look like they handle this, but they clear the property on themselves rather than on the ClientManager, so those calls have always been no-ops.unref()alone would not be enough: a live interval is a GC root, and its closure captures the manager, so the keepAlive agents, the client caches and the CredentialsManager stay reachable for the life of the process. The class gets aclose()instead, called by the services that own a manager once their consumers and producers are done with the clients.That matters more since BB-812, which made managers per endpoint and role rather than one per process. Looking at the other holders,
ReplicateObjectturned out to be the worse case: it built a brand-new manager for every entry it replicated, and another one on each retry that moved to the next host, dropping the previous one every time. Beyond the leak, each entry started from an empty credentials cache, so a role was assumed again for every single object. Those clients are now held on the queue processor and keyed by destination host and role, the way the copy location tasks already share theirs. The two caches stay separate because they assume their roles on different STS endpoints — the remote site's for the sources, the destination's for the targets.Idle managers are not evicted from either cache while the process runs; they drain their own credentials and clients, so what remains is the shell. Bounded by endpoints and roles rather than by object count, and followed up in BB-886.
Issue: BB-877