Repository navigation
[release-7.3] Fix stale peers for client facing roles (storage server, commit proxy, grv proxy) - #13367
Merged
Conversation
spraza
marked this pull request as draft
June 18, 2026 09:59
Contributor
Result of foundationdb-pr on Linux RHEL 9
|
Contributor
Result of foundationdb-pr-clang on Linux RHEL 9
|
Contributor
Result of foundationdb-pr-macos-m1 on macOS 14.x
|
Contributor
Result of foundationdb-pr-macos on macOS 14.x
|
Contributor
Result of foundationdb-pr-clang-73 on Linux CentOS 7
|
Contributor
Result of foundationdb-pr-73 on Linux CentOS 7
|
Contributor
Result of foundationdb-pr-cluster-tests-73 on Linux CentOS 7
|
spraza
commented
Jun 18, 2026
spraza
commented
Jun 18, 2026
spraza
commented
Jun 19, 2026
spraza
commented
Jun 19, 2026
spraza
commented
Jun 19, 2026
spraza
commented
Jun 19, 2026
Contributor
Result of foundationdb-pr-clang on Linux RHEL 9
|
Contributor
Result of foundationdb-pr on Linux RHEL 9
|
Contributor
Result of foundationdb-pr-macos-m1 on macOS 14.x
|
Contributor
Result of foundationdb-pr-macos on macOS 14.x
|
Contributor
Result of foundationdb-pr-clang-73 on Linux CentOS 7
|
Contributor
Result of foundationdb-pr-73 on Linux CentOS 7
|
Contributor
Result of foundationdb-pr-cluster-tests-73 on Linux CentOS 7
|
spraza
commented
Jun 21, 2026
Contributor
Result of foundationdb-pr-clang on Linux RHEL 9
|
Contributor
Result of foundationdb-pr on Linux RHEL 9
|
Contributor
Result of foundationdb-pr-macos-m1 on macOS 14.x
|
Contributor
Result of foundationdb-pr-macos on macOS 14.x
|
Collaborator
|
please merge in latest |
Contributor
Result of foundationdb-pr-clang-73 on Linux CentOS 7
|
Contributor
Result of foundationdb-pr-73 on Linux CentOS 7
|
Contributor
Result of foundationdb-pr-cluster-tests-73 on Linux CentOS 7
|
Contributor
Result of foundationdb-pr-macos-m1 on macOS 14.x
|
Contributor
Result of foundationdb-pr-macos on macOS 14.x
|
Contributor
Result of foundationdb-pr-macos-m1 on macOS 14.x
|
Contributor
Result of foundationdb-pr-clang-73 on Linux CentOS 7
|
Contributor
Result of foundationdb-pr-clang on Linux RHEL 9
|
Contributor
Result of foundationdb-pr-73 on Linux CentOS 7
|
Contributor
Result of foundationdb-pr on Linux RHEL 9
|
Contributor
Result of foundationdb-pr-macos on macOS 14.x
|
Contributor
Result of foundationdb-pr-cluster-tests-73 on Linux CentOS 7
|
Contributor
Result of foundationdb-pr-macos-m1 on macOS 14.x
|
Contributor
Result of foundationdb-pr-clang on Linux RHEL 9
|
Contributor
Result of foundationdb-pr-clang-73 on Linux CentOS 7
|
Contributor
Result of foundationdb-pr on Linux RHEL 9
|
Contributor
Result of foundationdb-pr-macos on macOS 14.x
|
Contributor
Result of foundationdb-pr-73 on Linux CentOS 7
|
Contributor
Result of foundationdb-pr-cluster-tests-73 on Linux CentOS 7
|
alecgrieser
approved these changes
Jun 29, 2026
gxglass
approved these changes
Jun 29, 2026
spraza
added a commit
to spraza/foundationdb
that referenced
this pull request
Aug 19, 2026
…, grv proxy) Client processes can keep stale RequestStream references to dead storage-server/proxy peers (via DatabaseContext::locationCache and MonitorLeader::shrinkProxyList's sampled subset), causing connection-timeout churn. Adds opt-in draining of dead-peer connections: a per-DatabaseContext peer evictor driven by a persistent per-address connect-failed counter, a shrinkProxyList cache clear below the connection cap, eager proxy rebuild on clientInfo change, and an InterfaceTracker observability layer (all gated by knobs, default off in production). invalidateCacheByAddress(es) processes ranges in chunks and yields between chunks to avoid hogging the event loop on large caches. Includes StalePeerTest, a deterministic repro workload. Ported from upstream/release-7.3 PR apple#13367 (51e1c42) and PR apple#13643 (805c271). Conflicts resolved in: tests/CMakeLists.txt, fdbclient/NativeAPI.actor.cpp, fdbclient/include/fdbclient/CommitProxyInterface.h, fdbclient/include/fdbclient/StorageServerInterface.h, fdbrpc/include/fdbrpc/FlowTransport.h, fdbserver/SimulatedCluster.actor.cpp.
spraza
added a commit
that referenced
this pull request
Aug 20, 2026
…, grv proxy) (#13912) Client processes can keep stale RequestStream references to dead storage-server/proxy peers (via DatabaseContext::locationCache and MonitorLeader::shrinkProxyList's sampled subset), causing connection-timeout churn. Adds opt-in draining of dead-peer connections: a per-DatabaseContext peer evictor driven by a persistent per-address connect-failed counter, a shrinkProxyList cache clear below the connection cap, eager proxy rebuild on clientInfo change, and an InterfaceTracker observability layer (all gated by knobs, default off in production). invalidateCacheByAddress(es) processes ranges in chunks and yields between chunks to avoid hogging the event loop on large caches. Includes StalePeerTest, a deterministic repro workload. Ported from upstream/release-7.3 PR #13367 (51e1c42) and PR #13643 (805c271). Conflicts resolved in: tests/CMakeLists.txt, fdbclient/NativeAPI.actor.cpp, fdbclient/include/fdbclient/CommitProxyInterface.h, fdbclient/include/fdbclient/StorageServerInterface.h, fdbrpc/include/fdbrpc/FlowTransport.h, fdbserver/SimulatedCluster.actor.cpp.
spraza
added a commit
that referenced
this pull request
Sep 17, 2026
* Fix stale peers for client facing roles (storage server, commit proxy, grv proxy) (#13912) Client processes can keep stale RequestStream references to dead storage-server/proxy peers (via DatabaseContext::locationCache and MonitorLeader::shrinkProxyList's sampled subset), causing connection-timeout churn. Adds opt-in draining of dead-peer connections: a per-DatabaseContext peer evictor driven by a persistent per-address connect-failed counter, a shrinkProxyList cache clear below the connection cap, eager proxy rebuild on clientInfo change, and an InterfaceTracker observability layer (all gated by knobs, default off in production). invalidateCacheByAddress(es) processes ranges in chunks and yields between chunks to avoid hogging the event loop on large caches. Includes StalePeerTest, a deterministic repro workload. Ported from upstream/release-7.3 PR #13367 (51e1c42) and PR #13643 (805c271). Conflicts resolved in: tests/CMakeLists.txt, fdbclient/NativeAPI.actor.cpp, fdbclient/include/fdbclient/CommitProxyInterface.h, fdbclient/include/fdbclient/StorageServerInterface.h, fdbrpc/include/fdbrpc/FlowTransport.h, fdbserver/SimulatedCluster.actor.cpp. (cherry picked from commit 2963ee8) * Enable stale peer fixes by default on main/8.0 Flip the three stale-peer client-facing mitigation knobs from off to on by default now that they have had bake time on 7.3/7.4: - location_cache_peer_evictor_enabled - shrink_proxy_list_clear_cache_below_threshold - dbcontext_eager_proxy_update The forward-port landed these off by default (opt-in). By the 8.0 cut they will have had sufficient production bake time, so main should ship with them on. The simulation randomization (coinflip under randomize && isSimulated) is left unchanged, so simulation still exercises both on and off states; only the production default changes. The stale_peer_observability tracing knob is intentionally left off (it is a debug aid, not a mitigation, and carries overhead). * fix clang-format * fix clang-tidy
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
When a server process a client talks to is killed (storage server, commit/grv proxy, etc.), the client can keep stale references to the dead process (via RequestStream). For example:
Storage servers:
DatabaseContext::locationCacheholds the dead SS'sStorageServerInterfaceuntil either a read hits that shard and fails (baseline error-driveninvalidateCache), orclientInfo/shard reassignment replaces it. ADatabaseContextthat doesn't actively read the affected shards (for example a server-hosted/internal client, or an idle one) can hold the dead SS's interface for a long time.Proxies: when the recruited proxy count exceeds
MAX_*_PROXY_CONNECTIONS,MonitorLeader::shrinkProxyListcaches a sampled subset (lastCommitProxies/lastGrvProxies). If a proxy is killed and the recruited count then drops back under the cap, the cached subset keeps pinning the killed proxy'sRequestStreams.Each pinned
RequestStreamholds aFlowTransportpeer reference, which keepsconnectionKeeperalive retrying the dead address. That produces connection-timeout (CTO) churn and wasted reconnect attempts. At scale this can show up as a problem with various symptoms.Solution
The core fixes make the client drain its connections to dead peers. Each fix is an opt-in knob (default off in production, randomized in simulation, forced on in the new test):
locationCachePeerEvictor(NativeAPI, knobLOCATION_CACHE_PEER_EVICTOR_ENABLED): a per-DatabaseContextactor that periodically (LOCATION_CACHE_PEER_EVICTOR_DELAY) samples FlowTransport's persistent per-address connect-failed counter, and for any address whose count went up beyondLOCATION_CACHE_PEER_EVICTOR_FAILED_THRESHOLDsince the previous sweep, callsinvalidateCacheByAddressto evict every cached location that references it. Dropping the cache'sReference<LocationInfo>lets the dead SS's streams release.FlowTransport, knobPERSISTENT_CONNECT_FAILED_COUNT_TTL):connectionKeeperrecords a per-destination cumulative connect-failure count plus last-failure time that survivesPeerdestruction. That's the stable signal the evictor reads. It's TTL-pruned to stay bounded.shrinkProxyListunder-cap cache-clear (MonitorLeader, knobSHRINK_PROXY_LIST_CLEAR_CACHE_BELOW_THRESHOLD): clears the cached sampled subset on iterations where the recruited count is below the cap, so a killed proxy's pinnedRequestStreams release.Eager proxy rebuild (knob
DBCONTEXT_EAGER_PROXY_UPDATE): rebuildscx->commitProxies/grvProxiesright away on aclientInfoproxy-list change instead of waiting for the next transaction's lazy lookup.Note: this PR is about the problem and the fix, but quite a lot of time was spent on figuring out where and what were the problems leading to high connection timeouts. These changes assisted with that:
InterfaceTracker(knobSTALE_PEER_OBSERVABILITY, default off): at various layers of the RPC stack, diagnostic per-(address, role) interface create/delete accounting plus per-ref backtraces. This helps get close to where the leak was coming from. Every method is a no-op when the knob is off.StalePeerTestworkload + toml: kills a configurable client-facing role, waits for recovery, then asserts no leaked interface copies (Delta == 0) remain on the client. A big part of this PR is a result of constant iteration on this failing test, and leveraging observability above to figure out why the test was failing. The goal was to make the test pass, and meanwhile, ensure general db functionality is not broken (general 100K signal).Testing
Simulation: ran
StalePeerTest10K times, all passed:20260622-234822-praza-stalepeer-v41m4-on7.3.77-c37d2130797b9 compressed=True data_size=34905210 duration=433655 ended=10000 fail_fast=100 max_runs=10000 pass=10000 priority=100 remaining=0 runtime=0:08:02 sanity=False started=10000 stopped=20260622-235624 submitted=20260622-234822 timeout=5400 username=praza-stalepeer-v41m4-on7.3.77-c37d2130797b99acc9da0313be445d751fee5d62
Simulation: ran the general 100K, all passed:
20260622-234826-praza-stalepeer-v41m4-on7.3.77-c37d2130797b9 compressed=True data_size=34872287 duration=3302230 ended=100000 fail_fast=10 max_runs=100000 pass=100000 priority=100 remaining=0 runtime=0:39:25 sanity=False started=100000 stopped=20260623-002751 submitted=20260622-234826 timeout=5400 username=praza-stalepeer-v41m4-on7.3.77-c37d2130797b99acc9da0313be445d751fee5d62
Perf cluster: saw up to a 100x reduction in CTO/min aggregated across clients (CTO = connection timeout).