Skip to content

Add PPAF write-region bookmark to CosmosDiagnostics - #50356

Open
Abhijeet Mohanty (jeet1995) wants to merge 4 commits into
Azure:mainfrom
jeet1995:users/abhmohanty/ppaf-cosmos-diagnostics
Open

Add PPAF write-region bookmark to CosmosDiagnostics#50356
Abhijeet Mohanty (jeet1995) wants to merge 4 commits into
Azure:mainfrom
jeet1995:users/abhmohanty/ppaf-cosmos-diagnostics

Conversation

@jeet1995

@jeet1995 Abhijeet Mohanty (jeet1995) commented Sep 3, 2026

Copy link
Copy Markdown
Member

Description

Adds a compact per-attempt ppaf bookmark to CosmosDiagnostics:

"ppaf": {
  "currWriteRegion": "east us",
  "since": "2026-09-03T12:34:56.789Z"
}

When PPAF has no designated override, diagnostics emit "ppaf": {}.

The designated region and timestamp are captured in an immutable, package-private snapshot when response statistics are recorded. This prevents later failover transitions or manager cleanup from rewriting historical diagnostics and avoids retaining endpoint-manager or routing state.

The compact ppaf object replaces the previous verbose PPAF diagnostics shape for both direct and gateway attempts.

@github-actions github-actions Bot added the Cosmos label Sep 3, 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.

@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 September 8, 2026 22:17
Copilot AI lite review requested due to automatic review settings September 8, 2026 22:17
@jeet1995 Abhijeet Mohanty (jeet1995) changed the title Add PPAF write-region bookmark to CosmosDiagnostics [WIP]: Add PPAF write-region bookmark to CosmosDiagnostics Sep 8, 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.

🟡 Changes recommended

The PR is marked WIP and there is a small diagnostics serialization consistency issue to address before approval.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR updates Azure Cosmos DB Java SDK diagnostics to emit a compact per-attempt Per-Partition Automatic Failover (PPAF) bookmark under the ppaf key, capturing the designated write region and the time it was designated, while ensuring historical diagnostics are immutable once recorded.

Changes:

  • Replaced the previous verbose PPAF diagnostics shape with a compact ppaf object (empty object when no override is active).
  • Introduced an immutable PerPartitionAutomaticFailoverDiagnostics snapshot that is captured and then attached to recorded response/gateway statistics.
  • Added/updated unit tests validating empty/populated PPAF diagnostics and record-time snapshot immutability.
File summaries
File Description
sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/perPartitionAutomaticFailover/PerPartitionAutomaticFailoverInfoHolder.java Stores and serializes a compact immutable PPAF diagnostics snapshot (ppaf) as {} or { currWriteRegion, since }.
sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/perPartitionAutomaticFailover/PerPartitionAutomaticFailoverDiagnostics.java New immutable snapshot type holding currWriteRegion and since for diagnostics serialization.
sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/perPartitionAutomaticFailover/PartitionLevelAutomaticFailoverInfo.java Adds since tracking and snapshots region/timestamp into the new immutable diagnostics object.
sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/ClientSideRequestStatistics.java Records PPAF snapshots at response/gateway record time and emits them under the ppaf field name.
sdk/cosmos/azure-cosmos/CHANGELOG.md Documents the new compact ppaf diagnostics bookmark behavior.
sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/GlobalPartitionEndpointManagerForPPAFUnitTests.java Adds tests asserting {} for empty PPAF and stable region/timestamp snapshots across direct and gateway stats.
Review details
  • Files reviewed: 6/6 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

@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) changed the title [WIP]: Add PPAF write-region bookmark to CosmosDiagnostics Add PPAF write-region bookmark to CosmosDiagnostics Sep 10, 2026
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