Prevent continuous connection rebuilding in custom upstreams #7789
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.
This commit fixes a critical performance issue with custom encrypted DNS upstreams configured for persistent clients. The bug caused connections to be unnecessarily closed and rebuilt on every DNS request, making custom DoH/DoT/DoQ upstreams 4-5 times slower than global upstreams.
The root cause was that after rebuilding a client's upstream connection, the timestamp
commonConfUpdate
used for detecting configuration changes was never updated. This resulted in an endless cycle of detecting "changes" and rebuilding connections on every request, particularly impacting encryption protocols with expensive connection establishment.This PR updates the client's configuration timestamp after rebuilding the connection in
upstreamManager.customUpstreamConfig()
.Fixes: #7739, #7769
Disclaimer: I have yet to test this. I don't have the time right now but will do later. If anyone else want to give this a try, please do.
edit: I've actually tested it now and I have not encountered the issue since then.