Skip to content

[WIP]: Improve PPCB failback diagnostics - #50122

Open
Abhijeet Mohanty (jeet1995) wants to merge 11 commits into
Azure:mainfrom
jeet1995:feature/per-partition-circuit-breaker-diagnostics
Open

[WIP]: Improve PPCB failback diagnostics#50122
Abhijeet Mohanty (jeet1995) wants to merge 11 commits into
Azure:mainfrom
jeet1995:feature/per-partition-circuit-breaker-diagnostics

Conversation

@jeet1995

Copy link
Copy Markdown
Member

Description

  • Emit a compact ppcb.stateByRegion snapshot for every PPCB-enabled routed request, including healthy empty state.
  • Preserve independent PPCB snapshots for direct and gateway request attempts.
  • Sample background failback failures with constant memory while retaining partition, region, stage, and reason in each message.
  • Log every failback error path and retry escaped recovery-stream failures so background recovery remains active until client close.

Testing

  • Focused Java 8 compilation
  • Direct TestNG execution: 11 passed, 0 failed, 0 skipped
  • git diff --check

@azure-pipelines

Copy link
Copy Markdown
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.

@jeet1995

Copy link
Copy Markdown
Member Author

/azp run java - cosmos - tests

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@jeet1995

Copy link
Copy Markdown
Member Author

/azp run java - cosmos - tests

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@jeet1995

Copy link
Copy Markdown
Member Author

/azp run java - cosmos - tests

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@jeet1995
Abhijeet Mohanty (jeet1995) marked this pull request as ready for review August 14, 2026 11:49
Copilot AI lite review requested due to automatic review settings August 14, 2026 11:49
@jeet1995 Abhijeet Mohanty (jeet1995) changed the title Improve PPCB failback diagnostics [WIP]: Improve PPCB failback diagnostics Aug 14, 2026
@azure-pipelines

Copy link
Copy Markdown
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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants