[WIP]: Improve PPCB failback diagnostics - #50122
Open
Abhijeet Mohanty (jeet1995) wants to merge 11 commits into
Open
[WIP]: Improve PPCB failback diagnostics#50122Abhijeet Mohanty (jeet1995) wants to merge 11 commits into
Abhijeet Mohanty (jeet1995) wants to merge 11 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. |
Member
Author
|
/azp run java - cosmos - tests |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
Member
Author
|
/azp run java - cosmos - tests |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
Member
Author
|
/azp run java - cosmos - tests |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
Abhijeet Mohanty (jeet1995)
marked this pull request as ready for review
August 14, 2026 11:49
Abhijeet Mohanty (jeet1995)
requested review from
a team and
Kiran Kumar Kolli (kirankumarkolli)
as code owners
August 14, 2026 11:49
Copilot started reviewing on behalf of
Abhijeet Mohanty (jeet1995)
August 14, 2026 11:50
View session
|
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. |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR enhances Azure Cosmos DB Java SDK Per-Partition Circuit Breaker (PPCB) diagnosability by ensuring routed requests consistently emit a compact ppcb.stateByRegion snapshot (including initialized empty state), and by improving failback observability with richer logging plus a new metric for pending failback recovery work.
Changes:
- Added a new client metric
cosmos.client.ppcb.failback.pendingRecoveryCount(gauge) to report pending partition range-region failback recovery actions per collection. - Refined PPCB diagnostics emission: snapshot semantics, stable serialization (
ppcb.stateByRegion), and distinct snapshots for direct vs gateway attempts. - Reworked failback recovery cycle to log key failure stages and keep background recovery active via retry behavior; added unit/E2E coverage around logging, diagnostics, and gauge behavior.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosMetricName.java | Adds the new PPCB failback pending recovery gauge metric and lookup mapping. |
| sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/perPartitionCircuitBreaker/PerPartitionCircuitBreakerInfoHolder.java | Introduces initialized/immutable snapshot semantics and renames serialized field to stateByRegion. |
| sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/perPartitionCircuitBreaker/GlobalPartitionEndpointManagerForPerPartitionCircuitBreaker.java | Refactors failback recovery loop, adds sampled failback logging, and publishes the new MultiGauge per collection. |
| sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/ClientSideRequestStatistics.java | Records PPCB snapshots at response time and standardizes diagnostics JSON field name to ppcb. |
| sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/CosmosAsyncClient.java | Wires client correlation id into PPCB logging and registers/unregisters the new failback gauge. |
| sdk/cosmos/azure-cosmos/CHANGELOG.md | Documents the new PPCB failback pending recovery gauge. |
| sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/PerPartitionCircuitBreakerE2ETests.java | Validates PPCB diagnostics always include ppcb.stateByRegion and expected health statuses. |
| sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/implementation/perPartitionCircuitBreaker/PpcbFailbackLoggingTest.java | Adds unit tests for failback logging sampling, recovery retry behavior, and gauge lifecycle/races. |
| sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/implementation/perPartitionCircuitBreaker/PerPartitionCircuitBreakerInfoHolderTest.java | Adds unit tests for immutability, serialization, and snapshot retention behavior. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+517
to
+525
| Flux<?> keepFailbackRecoveryAlive(Flux<?> recoveryWork) { | ||
| return recoveryWork | ||
| .doOnError(throwable -> this.logFailbackFailure( | ||
| null, | ||
| null, | ||
| "RECOVERY_STREAM", | ||
| throwable)) | ||
| .retry(); | ||
| } |
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.
Description
ppcb.stateByRegionsnapshot for every PPCB-enabled routed request, including healthy empty state.Testing
git diff --check