Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[rotor] delay proxy deregistration on disconnect (fixes #5792) (#5941)
This change fixes the pathology of an envoy in config loop causing a large spike in API requests. Inserting the delay itself is straightforward, and done as a Registrar decorator. Since registration/deregistration is idempotent, adding a delay in deregistration is sufficient; if another proxy comes along and registers during the delay, it gets the still present proxy configuration, and when the deregistration fires it just decrements the registration count. Doing this uncovered another problem in caching consumer, which is that there may be multiple requests pending for a given proxy on a stream, we were making no effort to track these, and we leak them on stream disconnect. So we introduce a `streamRefs` struct to track this. When a request is sent on a stream, we add a proxy ref for that stream ID. When a response is sent, we remove it. Most importantly, when the stream is closed, we remove all refs for the ID, which ensures that everything is properly deregistered. Along the way, factor out `onRequest` and `onResponse` from `OnFetchRequest` and `OnFetchResponse`, so they can be called with the correct stream ID from `OnStreamRequest` and `OnStreamResponse`. StreamIDs increment from 1, so a value of -1 is fine from the Fetch methods. Also, add some debug logging, and beef up test coverage. fbshipit-source-id: d8f2ba2
- Loading branch information
Showing
6 changed files
with
689 additions
and
41 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Oops, something went wrong.