Fix data race between rule-set updates and matching - #4353
Open
solodecode wants to merge 210 commits into
Open
Conversation
solodecode
marked this pull request as ready for review
July 27, 2026 02:12
`SecTrustEvaluateWithError` is serial
This reverts commit 62cb06c.
Since b0c6762, every rule inside a referenced rule-set was evaluated as if merged into the outer rule, which required tracking per-branch group states and let outer rules and rule-set rules satisfy each other's grouped conditions in both directions. Restrict merging to the only designed case: a rule-set containing exactly one non-inverted default rule is merged into the outer rule as before. Any other rule-set now matches as an ordinary condition of the outer rule: it matches when any of its rules matches on its own, and its rules no longer exchange grouped match state with the outer rule in either direction. Multiple referenced rule-sets keep OR semantics. Flat address rule-sets such as generated geosite/geoip sets contain a single default rule, so their behavior is unchanged. The group-state set machinery is replaced by a single required/satisfied mask pair. Also update the route and DNS rule docs.
solodecode
force-pushed
the
agent/fix-ruleset-reload-race
branch
from
July 27, 2026 13:43
00334d3 to
555ac63
Compare
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.
LocalRuleSet.reloadRulesandRemoteRuleSet.updateOncereplaces.rulesunderaccess, whileMatch,String,ExtractIPSet, andmergeableRuleread it without taking the lock. A local reload or remote update can therefore race with active route matching.Read
s.rulesthrough a snapshot taken underRLock, and protect the writes inCleanupandClosewithLock. Add a regression test that updates local and remote rule-sets while concurrent readers callMatch,String, andmergeableRule.Tested with
go test -race ./route/rule.