Commit e7b294a
committed
LEGLINK-958: Scope the retry-exhausted purge to acquisition keys only
The retry-exhausted purge deleted the {correlationId} key alongside the
{correlationId}:{Type} acquisition keys, on the premise that "nothing
downstream will ever consume it." That premise does not hold on this path.
ProcessMessageAsync produces ResourcesNormalized BEFORE deleting the
acquisition keys, so a failure at or after the produce - a client-side
produce timeout the broker actually accepted, or the trailing DeleteAsync
throwing - is classed transient and retried while the message is already
out. Measure Eval consumes it, finds the patient reportable, and
deliberately keeps {correlationId} for its SUPPLEMENTAL pass. When the
retries exhaust minutes later, purging that key makes the supplemental
read return empty, and Measure Eval "evaluat[es] with empty bundle to
produce a not-reportable report" - a silent false answer, not an error.
The handler cannot know whether an earlier attempt published; that
knowledge died with the attempt, and no transaction spans Kafka and the
cache. So the purge is now scoped by what each caller CAN prove:
ResourceCachePurgeScope.All
Immediate dead-letter path only. DeadLetterException is raised
exclusively by ValidateResourcesAcquiredEvent, before the processing
loop, so ResourcesNormalized was provably never produced and the
correlation key is safe to remove. A comment at the call site pins
that invariant: a DeadLetterException thrown after the produce would
invalidate it.
ResourceCachePurgeScope.AcquisitionKeysOnly
Retry exhaustion. Only the keys the message itself carries are
deleted; the derived correlation key is left to the cache expiration
policy. Cost: one leaked correlation hash per exhausted retry chain.
The alternative was a silently wrong clinical report.
The scope parameter has no default, so every future call site is forced
to answer "can the publish already have happened?" explicitly.
Tests: new purger test asserting AcquisitionKeysOnly leaves the
correlation key (watched failing with the scope deliberately ignored,
proving it detects the old behavior); both call sites' scope choices
pinned in their existing tests. Normalization unit tests 40/40.
Claude-Session: https://claude.ai/code/session_01AZubeEYCKfAmDCcgVTr18G1 parent 2752e6d commit e7b294a
6 files changed
Lines changed: 96 additions & 23 deletions
File tree
- DotNet
- Normalization
- Application
- Error
- Services
- Listeners
- ServiceTests/UnitTests/Normalization
Lines changed: 7 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
83 | 89 | | |
84 | 90 | | |
85 | 91 | | |
86 | | - | |
| 92 | + | |
87 | 93 | | |
88 | 94 | | |
89 | 95 | | |
| |||
Lines changed: 41 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
7 | 31 | | |
8 | 32 | | |
9 | 33 | | |
| |||
13 | 37 | | |
14 | 38 | | |
15 | 39 | | |
16 | | - | |
17 | | - | |
18 | | - | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
19 | 44 | | |
20 | 45 | | |
21 | 46 | | |
22 | 47 | | |
23 | | - | |
| 48 | + | |
24 | 49 | | |
25 | 50 | | |
26 | 51 | | |
| |||
35 | 60 | | |
36 | 61 | | |
37 | 62 | | |
38 | | - | |
| 63 | + | |
39 | 64 | | |
40 | 65 | | |
41 | 66 | | |
| |||
48 | 73 | | |
49 | 74 | | |
50 | 75 | | |
51 | | - | |
52 | | - | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
53 | 79 | | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
59 | 88 | | |
60 | 89 | | |
61 | 90 | | |
| |||
Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
187 | 187 | | |
188 | 188 | | |
189 | 189 | | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
190 | 196 | | |
191 | 197 | | |
192 | 198 | | |
| 199 | + | |
193 | 200 | | |
194 | 201 | | |
195 | 202 | | |
| |||
Lines changed: 31 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
| 27 | + | |
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| |||
33 | 33 | | |
34 | 34 | | |
35 | 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 | + | |
36 | 60 | | |
37 | 61 | | |
38 | 62 | | |
| |||
42 | 66 | | |
43 | 67 | | |
44 | 68 | | |
45 | | - | |
| 69 | + | |
46 | 70 | | |
47 | 71 | | |
48 | 72 | | |
| |||
61 | 85 | | |
62 | 86 | | |
63 | 87 | | |
64 | | - | |
| 88 | + | |
65 | 89 | | |
66 | 90 | | |
67 | 91 | | |
| |||
80 | 104 | | |
81 | 105 | | |
82 | 106 | | |
83 | | - | |
| 107 | + | |
84 | 108 | | |
85 | 109 | | |
86 | 110 | | |
| |||
92 | 116 | | |
93 | 117 | | |
94 | 118 | | |
95 | | - | |
| 119 | + | |
96 | 120 | | |
97 | 121 | | |
98 | 122 | | |
| |||
107 | 131 | | |
108 | 132 | | |
109 | 133 | | |
110 | | - | |
| 134 | + | |
111 | 135 | | |
112 | 136 | | |
113 | 137 | | |
| |||
Lines changed: 3 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| 47 | + | |
| 48 | + | |
47 | 49 | | |
48 | | - | |
| 50 | + | |
49 | 51 | | |
50 | 52 | | |
51 | 53 | | |
| |||
Lines changed: 7 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| 43 | + | |
43 | 44 | | |
44 | | - | |
45 | | - | |
| 45 | + | |
| 46 | + | |
46 | 47 | | |
47 | 48 | | |
48 | 49 | | |
| |||
51 | 52 | | |
52 | 53 | | |
53 | 54 | | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
54 | 59 | | |
55 | 60 | | |
56 | 61 | | |
| |||
0 commit comments