Fix PPCB failback with missing or stale addresses - #50182
Fix PPCB failback with missing or stale addresses#50182Annie Liang (xinlian12) merged 8 commits into
Conversation
|
Azure Pipelines: Successfully started running 2 pipeline(s). 33 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
There was a problem hiding this comment.
Pull request overview
Fixes a Per-Partition Circuit Breaker (PPCB) recovery edge case in the Cosmos direct connectivity stack where failback could get stuck if failover happens before the partition address cache is populated. The change ensures the recovery probe can resolve addresses via the gateway on a cache miss, and adds a regression unit test plus a changelog entry.
Changes:
- Update
GatewayAddressCache.submitOpenConnectionTasksto resolve partition addresses via gateway when the address-cache entry is missing. - Add a hermetic unit test covering the missing-cache path and verifying the resolved address is cached for subsequent probes.
- Document the fix in the unreleased Cosmos
CHANGELOG.md.
Show a summary per file
| File | Description |
|---|---|
| sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/directconnectivity/GatewayAddressCache.java | Adds cache-miss gateway address resolution before scheduling proactive open-connection tasks. |
| sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/implementation/directconnectivity/GatewayAddressCacheUnitTest.java | Adds a unit regression test validating cache-miss resolution and subsequent cache hit behavior. |
| sdk/cosmos/azure-cosmos/CHANGELOG.md | Notes the PPCB failback/cache-miss recovery fix in the unreleased bugs-fixed section. |
Review details
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
- Files reviewed: 3/3 changed files
- Comments generated: 1
- Review effort level: Lite
|
@sdkReviewAgent |
|
/azp run java - cosmos - tests |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
|
✅ Review complete (52:39) Posted 8 inline comment(s). Steps: ✓ context, correctness, cross-sdk, design, history, past-prs, synthesis, test-coverage |
|
@sdkReviewAgent |
|
✅ Review complete (28:51) Posted 3 inline comment(s). Steps: ✓ context, correctness, cross-sdk, design, history, past-prs, synthesis, test-coverage |
Resolve missing and stale partition addresses during PPCB recovery, retry forced address refreshes after network failures, and add cache-level, manager-level, and fault-injection coverage. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
51e4aca to
be0d92c
Compare
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
@sdkReviewAgent |
|
/azp run java - cosmos - tests |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
|
✅ Review complete (02:39) Posted 3 inline comment(s). Steps: ✓ context, correctness, cross-sdk, design, history, past-prs, synthesis, test-coverage |
Verify failover using a request issued after PPCB marks the original region unavailable instead of relying on the threshold-triggering request to be rerouted. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Skip unsupported gateway and thin-client test rows and preserve the existing configurable recovery-timeout minimum while using the new 20-second default. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Revert the recovery timeout configuration change and retain the existing ten-second default and minimum. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
/azp run java - cosmos - tests |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
Avoid exhausting the address-refresh fault exactly as PPCB opens, which allowed the background recovery sweep to clear the unavailable state before the test could observe failover. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
/azp run java - cosmos - tests |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
Do not require every stale replica probe to run after the first network failure terminates the pass. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
/azp run java - cosmos - tests |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
Issue
In some cases, the Per-Partition Circuit Breaker (PPCB) fails a partition over to another region but never fails it back to the preferred region, even after the preferred region becomes available again.
Root cause
This occurs when the partition address cache is not populated before PPCB failover. For example, the initial address refresh can fail with a 503 or connection timeout, leaving the partition with no cached addresses. The background recovery task previously assumed that a cache entry existed and attempted to open connections from a null entry, causing a
NullPointerExceptionand preventing recovery from completing.The failure workflow is:
NullPointerException.A related case can occur when the cache is populated but contains stale replica addresses: recovery probes those stale addresses and cannot reconnect after the backend addresses change.
Solution
The PPCB recovery path now:
Tests
Added coverage to the existing Cosmos test suites for:
GatewayAddressCacheTest.GlobalPartitionEndpointManagerForPPCBUnitTests.PerPartitionCircuitBreakerE2ETests: fault-injected address refresh failures leave the cache empty, PPCB fails the partition over, and background recovery later resolves the addresses and fails it back.