Commit 0c12e8e
QueryPlan : Fixes 410 Gone Exception on non-x64 platforms (#5257)
Windows 365 Defender team faced an issue with their HPK container set
up. Problem was when they set the root level partition key in the
QueryRequestOptions and run a query they would get the data back when
running on windows but for other environments(like docker) they were
getting an exception
For Docker they were getting 410(Gone) exception
Microsoft.Azure.Cosmos.CosmosException : Response status code does not
indicate success: Gone (410); Substatus: 1002; ActivityId:
623305e2-9a69-4b65-aa9b-911ee8ac3533; Reason: (Epk Range:
[0DCEB8CE51C6BFE84F4BD9409F69B9BB,0DCEB8CE51C6BFE84F4BD9409F69B9BBFF) is
gone.);
The root of the problem was that for non-window(x64) environment we were
getting the query plan from gateway(unlike windows where we use the
ServiceInterop dll) and after we got the plan we funnel it through
RequestInvokerHandler pipeline. The pipeline has a check where it sees
that if a feedRange is provided and if it returns more than 1
overlapping ranges it throws a gone exception but in this particular
case this is a valid scenario(edge case).
e.g
datatable (MinEPK: string, MaxEPK: string, PKrangeId)
[
"0D4DC2CD8F49C65A8E0C5306B61B4343","0DCEB8CE51C6BFE84F4BD9409F69B9BB2164DEBD78C50C850E0C1E3E3F0579ED",0
"0DCEB8CE51C6BFE84F4BD9409F69B9BB2164DEBD78C50C850E0C1E3E3F0579ED","1080F600C27CF98DC13F8639E94E7676"
1
]
If our provided partition key results in a hash e.g
0DCEB8CE51C6BFE84F4BD9409F69B9BB that lies between the above 2 records,
we will get overlapping ranges back.
Fix:
Fix it to explicitly make a check and see if its a Query Plan , if it is
then allow it to progress.
Testing:
I was able to get access to the Defender Team DB where they were facing
this issue. I manually tested the following E2E use cases and got the
desired results.
On Windows -> with PartitionKey specified
Diagnostics is : {"Summary":{"DirectCalls":{"(449, 5350)":6,"(200,
0)":2},"GatewayCalls":{"(200, 0)":4,"(304, 0)":1}}
Count: 24025; Severity: Medium;
Count: 24114; Severity: Informational;
Count: 23; Severity: High;
On Non_windows - with PartitionKey specified(in the QueryRequestOptions)
Diagnostics is : {"Summary":{"DirectCalls":{"(449, 5350)":2,"(200,
0)":2},"GatewayCalls":{"(200, 0)":5,"(304, 0)":1,"(0, 0)":1}}
Count: 24025; Severity: Medium;
Count: 24114; Severity: Informational;
Count: 23; Severity: High;
On Windows - no QueryRequestOption specified
Diagnostics is : {"Summary":{"DirectCalls":{"(200,
0)":2},"GatewayCalls":{"(200, 0)":4,"(304, 0)":1}}
Count: 24025; Severity: Medium;
Count: 24114; Severity: Informational;
Count: 23; Severity: High;
On Non_windows - no QueryRequestOption specified
Diagnostics is : {"Summary":{"DirectCalls":{"(200,
0)":2},"GatewayCalls":{"(200, 0)":5,"(304, 0)":1}}
Count: 24025; Severity: Medium;
Count: 24114; Severity: Informational;
Count: 23; Severity: High;
Problem writing a new reliable E2E test in the pipeline is the set up
needed to return overlapping ranges and we don't have control over when
partition split happens.
Talked to Ananth on how he tested it and he worked with Elasticity team
to create the database in the desired state, we can do the same in the
pipeline but need to check if our database accounts/containers get
cleaned up by some background job in the future(will check with Nalu on
this one).
I also explored the PartitionKeyHashRangeSplitterAndMerger class but
that works only with in-memory container and doesn't follow the
RequestInvokerHandler pipeline flow.
for the time being I added a unit test which will avoid any regression
in the future.
closes #5220
#5220
---------
Co-authored-by: Kiran Kumar Kolli <kirankk@microsoft.com>1 parent ea9a8a8 commit 0c12e8e
2 files changed
Lines changed: 154 additions & 11 deletions
File tree
- Microsoft.Azure.Cosmos
- src/Handler
- tests/Microsoft.Azure.Cosmos.Tests
Lines changed: 16 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
305 | 305 | | |
306 | 306 | | |
307 | 307 | | |
308 | | - | |
309 | | - | |
310 | | - | |
311 | | - | |
312 | | - | |
313 | | - | |
314 | | - | |
315 | | - | |
316 | | - | |
317 | | - | |
318 | | - | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
319 | 324 | | |
320 | 325 | | |
321 | 326 | | |
| |||
Lines changed: 138 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
| 9 | + | |
8 | 10 | | |
9 | 11 | | |
10 | 12 | | |
11 | 13 | | |
| 14 | + | |
12 | 15 | | |
| 16 | + | |
| 17 | + | |
13 | 18 | | |
14 | 19 | | |
15 | 20 | | |
| |||
18 | 23 | | |
19 | 24 | | |
20 | 25 | | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 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 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
21 | 159 | | |
22 | 160 | | |
23 | 161 | | |
| |||
0 commit comments