Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
kvcoord: optionally update range cache with descriptor returned in NLHE
We recently started shipping the range descriptors back on NotLeaseHolderError. Prior to this patch, we only ever used their generation to elide certain lease updates if they originated from a replica that had an older (stale) view of this world. This patch goes a step further in making use of the returned range descriptor -- we now update the client's range cache if the returned range descriptor is newer than what existed on the client. We do this by picking the freshest range descriptor and lease, independently, from the range descriptor/lease what exist in the client's range cache and what was returned in the NLHE. Though unlikely, independently choosing the freshest lease/range descriptor can lead to cases where the lease is not compatible with the range descriptor. If we detect this to be the case, we empty out the lease and simply cache the freshest range descriptor. Previously, we always accepted speculative leases to be more recent than anything already in the cache. Now, we discard speculative leases if they're coming from a replica that has an older view of the world. Morally, these semantics are the right way to conceptualize #72772, given that hazard could only ever exist for speculative leases. #82802 also falls out as a special case of this conceptualization, and this patch adds a regression test for the scenario where an uninitialized replica returns a NLHE with a speculative lease pointing to a replica that isn't part of the range. We also get rid of optimizations where we would try to identify "stale" range descriptors when updating lease information. These no longer make sense given we don't just update the lease, we also update the range descriptor. These optimizations also didn't account for all possible cases, such as when the leaseholder was present on the range descriptor, but as a LEARNER. See #75742 for more details about how this hazard manifests. With this new approach we also address #75742. Instead of invalidating the routing when a descriptor is identified as stale and using that as a proxy to bail early when routing to replicas, we instead switch to a more direct approach -- if at any point we detect the leaseholder isn't included on the transport, we exit the routing logic early, and retry at a layer above. Given our new range cache update semantics using descriptors on NLHE errors, it's quite likely this retry circumvents a range descriptor lookup from meta2 -- instead, we'd expect this to simply amount to trying again with a newly constructed transport. The rationale is that even though the client may have an arbitrarily stale view of the range, we never expect it to regress. Thus, if the leaseholder was updated on the client and it doesn't exist on the transport, it must be the case that the transport was constructed using a stale range descriptor and stale leaseholder information. As such, there is likely not much value in trying to exhaust the transport (and potentially getting caught in backoff loops). We're much better served by bailing early and trying again with a fresh transport. Fixes #82802 Fixes #75742 Release note: None Release justification: Fixes for high priority bugs in existing functionality.
- Loading branch information