Commit 562d2d5
[Internal] PPAF: Fixes Hub region header never sent due to premature NoRetry on single-master 404/1002. (#5792)
# Pull Request Template
## Description
# PR Description
## Summary
Fixes a bug in `ClientRetryPolicy.ShouldRetryOnSessionNotAvailable`
where the hub region processing header
(`x-ms-cosmos-hub-region-processing-only`) was set but **never actually
sent** to the backend on single-master accounts. The retry threshold
`sessionTokenRetryCount > 1` caused `NoRetry` immediately after the
header flag was set, preventing the retry that would carry the header.
## Fix
Changed `sessionTokenRetryCount > 1` → `sessionTokenRetryCount > 2`.
### Corrected Flow
| Attempt | `count` before method | Guard sets header? | `count++` |
Check `count > 2` | Result | Header on request? |
|---------|----------------------|-------------------|-----------|-------------------|--------|--------------------|
| 1st request | — | — | — | — | Sent to preferred read region | ❌ No |
| 1st 404/1002 | 0 | No (`0 >= 1` = false) | → 1 | `1 > 2` = false | ✅
Retry to write region (index=0) | ❌ No |
| 2nd 404/1002 | 1 | **Yes** (`1 >= 1` = true) | → 2 | `2 > 2` = false |
✅ Retry to write region (index=0) | ✅ **Yes** |
| 3rd 404/1002 | 2 | Yes (already true) | → 3 | `3 > 2` = true | ⛔
NoRetry — hub confirmed not available | ✅ Yes |
### End-to-End Hub Region Discovery (Happy Path with 403/3)
| Step | Request | Response | Hub Header? | What happens |
|------|---------|----------|-------------|-------------|
| 1 | Read to preferred region | 404/1002 | ❌ | Session not available →
retry to write region |
| 2 | Read to write region | 404/1002 | ❌ | Write region also returns
session not available → header flag set → retry |
| 3 | Read to write region | 403/3 | ✅ | Non-hub region rejects hub-only
request → PPAF marks endpoint unavailable → retry to next region |
| 4 | Read to next region | 200 OK | ✅ | Hub region found, request
succeeds, hub cached for partition |
## Type of change
Please delete options that are not relevant.
- [X] Bug fix (non-breaking change which fixes an issue)
## Closing issues
To automatically close an issue: closes #IssueNumber
---------
Co-authored-by: Debdatta Kunda <87335885+kundadebdatta@users.noreply.github.com>1 parent 377c5b5 commit 562d2d5
4 files changed
Lines changed: 235 additions & 65 deletions
File tree
- Microsoft.Azure.Cosmos
- src
- tests
- Microsoft.Azure.Cosmos.EmulatorTests
- Microsoft.Azure.Cosmos.Tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
| |||
331 | 332 | | |
332 | 333 | | |
333 | 334 | | |
334 | | - | |
335 | | - | |
336 | | - | |
337 | | - | |
338 | | - | |
339 | | - | |
340 | | - | |
341 | | - | |
342 | 335 | | |
343 | 336 | | |
344 | 337 | | |
| |||
456 | 449 | | |
457 | 450 | | |
458 | 451 | | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
459 | 468 | | |
460 | 469 | | |
461 | | - | |
462 | | - | |
| 470 | + | |
| 471 | + | |
463 | 472 | | |
464 | 473 | | |
| 474 | + | |
465 | 475 | | |
466 | 476 | | |
467 | 477 | | |
| |||
Lines changed: 26 additions & 16 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4319 | 4319 | | |
4320 | 4320 | | |
4321 | 4321 | | |
4322 | | - | |
| 4322 | + | |
| 4323 | + | |
4323 | 4324 | | |
4324 | 4325 | | |
4325 | 4326 | | |
4326 | 4327 | | |
4327 | | - | |
| 4328 | + | |
| 4329 | + | |
4328 | 4330 | | |
4329 | 4331 | | |
4330 | 4332 | | |
| |||
4338 | 4340 | | |
4339 | 4341 | | |
4340 | 4342 | | |
4341 | | - | |
4342 | | - | |
4343 | | - | |
4344 | | - | |
| 4343 | + | |
| 4344 | + | |
| 4345 | + | |
| 4346 | + | |
4345 | 4347 | | |
4346 | | - | |
| 4348 | + | |
4347 | 4349 | | |
4348 | 4350 | | |
4349 | | - | |
| 4351 | + | |
| 4352 | + | |
| 4353 | + | |
| 4354 | + | |
| 4355 | + | |
| 4356 | + | |
| 4357 | + | |
| 4358 | + | |
| 4359 | + | |
4350 | 4360 | | |
4351 | 4361 | | |
4352 | 4362 | | |
| |||
4399 | 4409 | | |
4400 | 4410 | | |
4401 | 4411 | | |
4402 | | - | |
4403 | | - | |
| 4412 | + | |
4404 | 4413 | | |
4405 | 4414 | | |
4406 | 4415 | | |
| |||
4409 | 4418 | | |
4410 | 4419 | | |
4411 | 4420 | | |
4412 | | - | |
| 4421 | + | |
4413 | 4422 | | |
4414 | 4423 | | |
4415 | 4424 | | |
4416 | 4425 | | |
4417 | 4426 | | |
4418 | | - | |
4419 | | - | |
4420 | | - | |
4421 | | - | |
4422 | | - | |
| 4427 | + | |
| 4428 | + | |
| 4429 | + | |
| 4430 | + | |
| 4431 | + | |
| 4432 | + | |
4423 | 4433 | | |
4424 | 4434 | | |
4425 | 4435 | | |
| |||
0 commit comments