Repository navigation
Commit 438fa7f
Fix source-specific response cache eligibility (#3923)
## Why make this change?
- Response-cache eligibility checked the default data source's
session-context setting instead of the queried source. In multi-source
configurations, a child SQL source using session-context row-level
security could consequently reuse another caller's cached response.
## What is this change?
- Add source-aware cache eligibility while retaining the default-source
API.
- Bypass response-cache reads and writes for queried MSSQL/DWSQL sources
with `set-session-context` enabled, including stored procedures and
cache-control paths.
- Pass the actual source name through SQL and Cosmos query engines,
preserving caching for eligible child sources.
- Compute effective runtime cache telemetry across loaded sources and
effective entity cache telemetry using each entity's source.
- Add regression tests and update [query-caching
documentation](https://github.com/Azure/data-api-builder/blob/177eca3e899f6f8ffc28f4fbcab9093c08145b9d/docs/design/query-caching.md)
and [cache telemetry
documentation](https://github.com/Azure/data-api-builder/blob/177eca3e899f6f8ffc28f4fbcab9093c08145b9d/docs/testing-guide/engine-telemetry.md).
## How was this tested?
- [ ] Integration Tests
- [x] Unit Tests
- Targeted suite: **154 passed, 0 failed, 0 skipped** across
`SourceAwareCacheTests`, `DabCacheServiceIntegrationTests`,
`RuntimeConfigHelperTests`, and `EngineTelemetrySnapshotTests`.
- Regression cases exercise the public SQL query-engine APIs with real
FusionCache and synthetic database responses: a preexisting cached
response is bypassed after enabling session context, Bob/anonymous
receive their own synthetic results, and protected-source reads do not
overwrite the old cache entry.
- Cover MSSQL/DWSQL, stored procedures, default reads, `no-store`,
`no-cache`, `only-if-cached`, source-option updates, global cache
disablement, eligible child caching, and source-aware telemetry.
- Focused `dotnet format --verify-no-changes` and `git diff --check`
passed.
## Sample Request(s)
For an authorized read against an entity on a child MSSQL/DWSQL source
with `set-session-context: true`:
```http
GET /api/Notes
```
The request must reach the database for each caller rather than reuse
another caller's cached result. The same source-specific bypass applies
to the cache-control variants, for example:
```http
GET /api/Notes
Cache-Control: no-store
```
Caching remains available for an eligible child source even when session
context is enabled on the default source. No CLI changes.
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Souvik Ghosh <souvikofficial04@gmail.com>
Co-authored-by: souvikghosh04 <210500244+souvikghosh04@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>1 parent 3243510 commit 438fa7f
12 files changed
Lines changed: 351 additions & 21 deletions
File tree
- docs
- design
- testing-guide
- src
- Config/ObjectModel
- Core
- Resolvers
- Telemetry/Product
- Service.Tests
- Caching
- Telemetry
- UnitTests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | 1 | | |
3 | 2 | | |
4 | 3 | | |
| |||
96 | 95 | | |
97 | 96 | | |
98 | 97 | | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
99 | 106 | | |
100 | 107 | | |
101 | 108 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
142 | 142 | | |
143 | 143 | | |
144 | 144 | | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
145 | 151 | | |
146 | 152 | | |
147 | 153 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
677 | 677 | | |
678 | 678 | | |
679 | 679 | | |
680 | | - | |
681 | | - | |
682 | | - | |
| 680 | + | |
683 | 681 | | |
684 | 682 | | |
685 | 683 | | |
686 | 684 | | |
687 | | - | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
688 | 699 | | |
689 | 700 | | |
690 | 701 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
95 | | - | |
| 95 | + | |
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
325 | 325 | | |
326 | 326 | | |
327 | 327 | | |
328 | | - | |
329 | | - | |
| 328 | + | |
330 | 329 | | |
331 | 330 | | |
332 | 331 | | |
| |||
468 | 467 | | |
469 | 468 | | |
470 | 469 | | |
471 | | - | |
472 | | - | |
473 | | - | |
474 | | - | |
| 470 | + | |
475 | 471 | | |
476 | 472 | | |
477 | 473 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
229 | 230 | | |
230 | 231 | | |
231 | 232 | | |
| 233 | + | |
232 | 234 | | |
233 | 235 | | |
234 | 236 | | |
235 | 237 | | |
236 | 238 | | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
237 | 248 | | |
238 | 249 | | |
239 | 250 | | |
| |||
256 | 267 | | |
257 | 268 | | |
258 | 269 | | |
259 | | - | |
| 270 | + | |
260 | 271 | | |
261 | 272 | | |
262 | 273 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
53 | | - | |
| 53 | + | |
| 54 | + | |
54 | 55 | | |
55 | 56 | | |
56 | 57 | | |
| |||
71 | 72 | | |
72 | 73 | | |
73 | 74 | | |
74 | | - | |
| 75 | + | |
75 | 76 | | |
76 | 77 | | |
77 | 78 | | |
| |||
268 | 269 | | |
269 | 270 | | |
270 | 271 | | |
271 | | - | |
| 272 | + | |
| 273 | + | |
272 | 274 | | |
273 | 275 | | |
274 | 276 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
788 | 788 | | |
789 | 789 | | |
790 | 790 | | |
791 | | - | |
| 791 | + | |
792 | 792 | | |
793 | 793 | | |
794 | 794 | | |
| |||
0 commit comments