dnsforward: build new server state before stopping the old one - #8589
Open
ChenYun10 wants to merge 1 commit into
Open
dnsforward: build new server state before stopping the old one#8589ChenYun10 wants to merge 1 commit into
ChenYun10 wants to merge 1 commit into
Conversation
Reconfigure previously stopped the running proxy first, then slept for 100 ms, and only then prepared the new state. This kept the listeners down for the whole (potentially slow) preparation — including upstream loading and bootstrap resolution — and made clients get "connection refused" during every settings change. Build the new state before tearing the old one down, and remove the blind 100 ms sleep. The old proxy and its resources are shut down explicitly after the new state is prepared, shrinking the actual downtime window to just the final swap and start. Signed-off-by: Chen Yun <ChenYun10@users.noreply.github.com>
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.
Problem
Server.Reconfigurecurrently stops the running proxy first, then does a blindtime.Sleep(100 * time.Millisecond), and only then prepares the new state (loading upstreams, bootstrapping, building the filtering proxy). During this whole window the listeners are down and clients get "connection refused" on every settings change.Fix
Build the new state before tearing the old one down, and remove the 100 ms sleep. The old proxy, bootstrap resolvers and address processor are shut down explicitly after the new state is prepared, shrinking the actual downtime to just the final swap and start.
Notes
serverLockis still held for the whole operation (it serializes request handling). A full fix would build the new proxy outside the lock and only swap under a brief critical section; that is left as a follow-up sincePreparecurrently mutates many fields ofs.go build ./...andgo test ./internal/dnsforward/pass; smoke-tested by triggeringPOST /control/dns_configand observing the reconfiguration complete in ~2 ms with DNS resolution continuing afterwards.Signed-off-by: Chen Yun <zouminchen09@gmail .com>