Commit 09d85ce
Emit x-ms-cosmos-hub-region-processing-only header (#4389)
Implements
[`HUB_REGION_PROCESSING_HEADER_SPEC.md`](https://github.com/Azure/azure-sdk-for-rust/blob/release/azure_data_cosmos-previews/sdk/cosmos/azure_data_cosmos/docs/HUB_REGION_PROCESSING_HEADER_SPEC.md)
(merged in #4320) for single-master data-plane Cosmos operations.
On the retry triggered by the first `404 / 1002
(READ_SESSION_NOT_AVAILABLE)` response, the driver now latches a
per-operation flag and emits the
`x-ms-cosmos-hub-region-processing-only: True` request header on every
subsequent transport attempt for that operation. This asks the backend
to route only to a region that has caught up to the requested LSN,
reducing the chance of a follow-up retry hitting another region whose
session is also behind.
The latch is sticky for the remainder of the operation and gated on
three conditions, which together scope the change exactly to the case
the spec calls out:
- data-plane scope (metadata-pipeline ops are out of scope per spec
§1.5)
- single-master accounts (multi-master accounts already have a different
recovery path)
- first 1002 within the operation (subsequent 1002s preserve the latch
but don't re-arm it)
Mirrors .NET parity
([Azure/azure-cosmos-dotnet-v3#5447](Azure/azure-cosmos-dotnet-v3#5447)).
Forward-compatible by design: backends that ignore the header preserve
the existing single-master 1002 retry behavior, so this lands safely
ahead of the server-side rollout.
## Changes by file
- **`cosmos_headers.rs`** — adds `HUB_REGION_PROCESSING_ONLY` const
inside `request_header_names`.
- **`components.rs`** — adds `is_dataplane: bool` and
`hub_region_processing_only: bool` fields to `OperationRetryState` with
LOAD-BEARING doc comments; `initial()` defaults both to `false`;
invariant note added to `session_token_retry_count` because the latch
trigger reads it pre-increment. `advance_*` propagates the flags
automatically via `..self` — no new positional parameters.
- **`operation_pipeline.rs`** — sets `retry_state.is_dataplane =
pipeline_type.is_data_plane()` once at the production call site (uses
the accessor because `PipelineType` is `#[non_exhaustive]` — a future
variant must not silently bypass an equality gate); extracts
`apply_hub_region_header(..)` as a small free function so the emission
rule can be tested without driving the full pipeline; updates 5 existing
exhaustive `OperationRetryState` struct-literal tests for the two new
fields.
- **`retry_evaluation.rs`** — extracts `build_session_retry_state(..)`
that latches `hub_region_processing_only` when all four trigger
conditions hold; gate placed after the existing `>= 2` abort check so it
only runs on the SessionRetry path; updates the one exhaustive
struct-literal test for the two new fields.
- **`azure_data_cosmos_driver/CHANGELOG.md`** and
**`azure_data_cosmos/CHANGELOG.md`** — entries under the unreleased
version with a back-link to #4320 and the spec doc.
## Tests added (10)
Trigger-side coverage in `retry_evaluation::tests` (8):
single-master/data-plane first 1002 latches (AC-1); multi-master never
latches (AC-4); latch stays set across subsequent 1002s (AC-2);
200/410/503 never latch (AC-5); count boundary at exhaustion (AC-3);
metadata-pipeline never latches (AC-8); independent operations don't
share state (AC-6); latch survives failover via `..self` propagation.
Emission-side coverage in `operation_pipeline::tests` (2): header set to
`True` when latched; header omitted when not latched.
All 876 lib tests + 57 in-memory-emulator tests + 40 emulator tests
pass; `cargo fmt` and `cargo clippy --all-features --tests` are clean.
## Acceptance criteria
AC-1 through AC-6 and AC-8 from the spec are covered by the tests above.
AC-7 (long-tail recovery / per-region telemetry) is deferred per the
spec's ALT-5 — no client-side scope.
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 0627369 commit 09d85ce
6 files changed
Lines changed: 486 additions & 5 deletions
File tree
- sdk/cosmos
- azure_data_cosmos_driver
- src
- driver/pipeline
- models
- azure_data_cosmos
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
9 | 8 | | |
| 9 | + | |
10 | 10 | | |
11 | | - | |
12 | 11 | | |
13 | | - | |
14 | 12 | | |
15 | 13 | | |
16 | 14 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
Lines changed: 56 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
78 | 86 | | |
79 | 87 | | |
80 | 88 | | |
81 | 89 | | |
82 | 90 | | |
83 | 91 | | |
84 | 92 | | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
85 | 139 | | |
86 | 140 | | |
87 | 141 | | |
| |||
164 | 218 | | |
165 | 219 | | |
166 | 220 | | |
| 221 | + | |
| 222 | + | |
167 | 223 | | |
168 | 224 | | |
169 | 225 | | |
| |||
Lines changed: 124 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
140 | 140 | | |
141 | 141 | | |
142 | 142 | | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
143 | 155 | | |
144 | 156 | | |
145 | 157 | | |
| |||
153 | 165 | | |
154 | 166 | | |
155 | 167 | | |
156 | | - | |
| 168 | + | |
157 | 169 | | |
158 | 170 | | |
159 | 171 | | |
| |||
185 | 197 | | |
186 | 198 | | |
187 | 199 | | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
188 | 208 | | |
189 | 209 | | |
190 | 210 | | |
| |||
923 | 943 | | |
924 | 944 | | |
925 | 945 | | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
| 957 | + | |
| 958 | + | |
| 959 | + | |
| 960 | + | |
| 961 | + | |
| 962 | + | |
| 963 | + | |
| 964 | + | |
| 965 | + | |
| 966 | + | |
| 967 | + | |
| 968 | + | |
| 969 | + | |
| 970 | + | |
| 971 | + | |
| 972 | + | |
| 973 | + | |
| 974 | + | |
| 975 | + | |
| 976 | + | |
| 977 | + | |
| 978 | + | |
| 979 | + | |
926 | 980 | | |
927 | 981 | | |
928 | 982 | | |
| |||
1333 | 1387 | | |
1334 | 1388 | | |
1335 | 1389 | | |
| 1390 | + | |
| 1391 | + | |
1336 | 1392 | | |
1337 | 1393 | | |
1338 | 1394 | | |
| |||
1387 | 1443 | | |
1388 | 1444 | | |
1389 | 1445 | | |
| 1446 | + | |
| 1447 | + | |
1390 | 1448 | | |
1391 | 1449 | | |
1392 | 1450 | | |
| |||
1441 | 1499 | | |
1442 | 1500 | | |
1443 | 1501 | | |
| 1502 | + | |
| 1503 | + | |
1444 | 1504 | | |
1445 | 1505 | | |
1446 | 1506 | | |
| |||
1502 | 1562 | | |
1503 | 1563 | | |
1504 | 1564 | | |
| 1565 | + | |
| 1566 | + | |
1505 | 1567 | | |
1506 | 1568 | | |
1507 | 1569 | | |
| |||
1761 | 1823 | | |
1762 | 1824 | | |
1763 | 1825 | | |
| 1826 | + | |
| 1827 | + | |
1764 | 1828 | | |
1765 | 1829 | | |
1766 | 1830 | | |
| |||
2736 | 2800 | | |
2737 | 2801 | | |
2738 | 2802 | | |
| 2803 | + | |
| 2804 | + | |
| 2805 | + | |
| 2806 | + | |
| 2807 | + | |
| 2808 | + | |
| 2809 | + | |
| 2810 | + | |
| 2811 | + | |
| 2812 | + | |
| 2813 | + | |
| 2814 | + | |
| 2815 | + | |
| 2816 | + | |
| 2817 | + | |
| 2818 | + | |
| 2819 | + | |
| 2820 | + | |
| 2821 | + | |
| 2822 | + | |
| 2823 | + | |
| 2824 | + | |
| 2825 | + | |
| 2826 | + | |
| 2827 | + | |
| 2828 | + | |
| 2829 | + | |
| 2830 | + | |
| 2831 | + | |
| 2832 | + | |
| 2833 | + | |
| 2834 | + | |
| 2835 | + | |
| 2836 | + | |
| 2837 | + | |
| 2838 | + | |
| 2839 | + | |
| 2840 | + | |
| 2841 | + | |
| 2842 | + | |
| 2843 | + | |
| 2844 | + | |
| 2845 | + | |
| 2846 | + | |
| 2847 | + | |
| 2848 | + | |
| 2849 | + | |
| 2850 | + | |
| 2851 | + | |
| 2852 | + | |
| 2853 | + | |
| 2854 | + | |
| 2855 | + | |
| 2856 | + | |
| 2857 | + | |
| 2858 | + | |
| 2859 | + | |
| 2860 | + | |
| 2861 | + | |
2739 | 2862 | | |
2740 | 2863 | | |
2741 | 2864 | | |
| |||
0 commit comments