This repository was archived by the owner on Aug 25, 2025. It is now read-only.
junction-core: Fix an add-remove-add caching bug#179
Merged
Conversation
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
We managed to turn up an add-remove-add bug where the client cache was marking an xDS Cluster as not-found when removing it instead of just removing it from the cache. This was, unfortunately, fairly easy to turn up - speeding up ingest and changing route names in the smoke test (a6cb862) were enough to trigger it reliably.
The fix is trivial - on removing a resource from the cache, don't create a subscription node if one doesn't already exist.
fn remove(&mut self, rtype: ResourceType, name: &str) { - if let Some(sub) = self.find_subcribed(rtype, name) { + if let Some(sub) = self.find(rtype, name) { self.reset_refs(sub); } }For resources that are not wildcards, this was a noop, but for Clusters this would both tombstone resource data and create a wildcard subscription, which marks the resource as not-found.
Most of the fix is a connection level test I wrote trying to reproduce, and a cache-level test that scopes this more tightly. To repro, it was necessary to interleave a call to
cache.collectbetween removing a reference to the cluster from the RouteConfig and removing the cluster itself from the cache.More Debugging Tools
While reproducing, it was useful to have tracing enabled in Rust. Enabling tracing doesn't happen automatically, but there is now a hook that Python clients can call to enable the standard tracing subscriber. This isn't the best interface but is an improvement.