Commit ed52df8
fix(conclude): publish request log on terminal reconcile + make idempotent (#198)
## Summary
The conclude controller reconciles each request in a concluded batch to
the batch's terminal state (Landed / Error / Cancelled) but did not emit
a corresponding `RequestLog` entry, leaving the request lifecycle log
without a terminal record. Peer controllers (`start`, `score`, `cancel`)
already publish to the log topic on their transitions; this brings
`conclude` in line.
The per-request loop is also made idempotent under at-least-once
redelivery:
- **Already in target terminal state** → skip the CAS but **still
publish the log**. The log queue dedupes on `(request_id, status)`, so a
prior delivery that completed the state update but failed before
publishing the log gets its log emitted on retry, recorded exactly once.
- **In a different terminal state** (a racing writer reached terminal
first) → skip both the CAS and the log publish; the other writer owns
the terminal log entry for the state it wrote. Recorded via a
`terminal_state_divergence` metric and a warning log.
- **Not terminal** → CAS to target state, then publish log.
## Test plan
- [x] `bazel test
//submitqueue/orchestrator/controller/conclude:conclude_test` passes
- [x] Added test case: idempotent retry — request already `Landed`, no
`UpdateState` mocked (gomock would fail if called), publisher still
expected
- [x] Added test case: divergent terminal state — request already
`Cancelled` for a `Succeeded` batch; neither `UpdateState` nor publish
allowed
- [x] Existing cases updated to expect log publish on the happy path
- [x] `make gazelle` clean (picks up new `submitqueue/core/request` dep)
- [x] `make fmt` clean
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: sergeyb <sergeyb@uber.com>
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>1 parent f17c76f commit ed52df8
3 files changed
Lines changed: 164 additions & 25 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
Lines changed: 64 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
| |||
101 | 102 | | |
102 | 103 | | |
103 | 104 | | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
104 | 110 | | |
105 | | - | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
106 | 116 | | |
107 | 117 | | |
108 | 118 | | |
109 | 119 | | |
110 | 120 | | |
111 | 121 | | |
112 | 122 | | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
| 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 | + | |
117 | 155 | | |
118 | | - | |
119 | 156 | | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
125 | 164 | | |
126 | 165 | | |
127 | 166 | | |
| |||
155 | 194 | | |
156 | 195 | | |
157 | 196 | | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
Lines changed: 99 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | | - | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
45 | 48 | | |
46 | 49 | | |
47 | 50 | | |
| |||
53 | 56 | | |
54 | 57 | | |
55 | 58 | | |
56 | | - | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
57 | 71 | | |
58 | 72 | | |
59 | | - | |
| 73 | + | |
60 | 74 | | |
61 | 75 | | |
62 | 76 | | |
63 | 77 | | |
64 | | - | |
| 78 | + | |
65 | 79 | | |
66 | 80 | | |
67 | 81 | | |
| |||
71 | 85 | | |
72 | 86 | | |
73 | 87 | | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
79 | 94 | | |
80 | 95 | | |
81 | 96 | | |
| |||
111 | 126 | | |
112 | 127 | | |
113 | 128 | | |
| 129 | + | |
114 | 130 | | |
115 | 131 | | |
116 | 132 | | |
| |||
142 | 158 | | |
143 | 159 | | |
144 | 160 | | |
| 161 | + | |
145 | 162 | | |
146 | 163 | | |
147 | 164 | | |
| |||
173 | 190 | | |
174 | 191 | | |
175 | 192 | | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
176 | 261 | | |
177 | 262 | | |
178 | 263 | | |
| |||
201 | 286 | | |
202 | 287 | | |
203 | 288 | | |
204 | | - | |
| 289 | + | |
205 | 290 | | |
206 | 291 | | |
207 | 292 | | |
| |||
231 | 316 | | |
232 | 317 | | |
233 | 318 | | |
234 | | - | |
| 319 | + | |
235 | 320 | | |
236 | 321 | | |
237 | 322 | | |
| |||
296 | 381 | | |
297 | 382 | | |
298 | 383 | | |
299 | | - | |
| 384 | + | |
300 | 385 | | |
301 | 386 | | |
302 | 387 | | |
| |||
324 | 409 | | |
325 | 410 | | |
326 | 411 | | |
327 | | - | |
| 412 | + | |
328 | 413 | | |
329 | 414 | | |
330 | 415 | | |
| |||
338 | 423 | | |
339 | 424 | | |
340 | 425 | | |
341 | | - | |
| 426 | + | |
342 | 427 | | |
343 | 428 | | |
344 | 429 | | |
0 commit comments