Commit 2b96045
[OPIK-8240] [BE] fix: split provider-error retryability by status, resume XAUTOCLAIM from its cursor
Two independent defects that each leave a permanently failing online-scoring
message cycling instead of retiring it.
1. A permanent provider 4xx was retried as if transient.
ChatCompletionService.scoreTrace answered every unmappable provider failure
with a blanket InternalServerErrorException, which sits outside
BaseRedisSubscriber.NON_RETRYABLE_EXCEPTIONS -- so a request that can never
succeed was replayed maxRetries times, once per pendingMessageDuration. The
real status was available the whole time on the HttpException in the cause
chain; it went unread because the existing recovery path classifies by family,
and mapping all of 4xx to ClientErrorException would drop transient 408/429
after one attempt.
Classify by status code instead: 400/401/403 and the rest of 4xx are
permanent, 408/425/429 and all 5xx stay retryable. scoreTrace gets its own
mapping so create() and the streaming handler keep returning the provider's
status verbatim to HTTP callers. This also closes a pre-existing over-eager
drop on the parseable branch, where a JSON-parseable 429 already became
ClientErrorException and was dropped after one attempt.
2. XAUTOCLAIM never scanned past the first ~100 pending entries.
claimPendingMessages passed StreamMessageId.MIN as the scan start every call
and discarded the cursor Redis returns. Redis caps each XAUTOCLAIM at
COUNT * 10 PEL entries *examined*, so at consumerBatchSize=10 a call inspects
only the first 100 -- and restarting at MIN means nothing past that window is
ever examined. Any backlog above ~100 grows a permanently unreachable tail.
Carry getNextId() forward, resetting to MIN on Redis's 0-0 end-of-pass reply.
A failed scan deliberately does not advance the cursor, so its window is
retried rather than skipped. The sentinel is compared numerically:
StreamMessageId.MIN/.ALL serialize to "-" and "0" and neither is equals() to
the StreamMessageId(0, 0) Redisson parses 0-0 into (verified against redisson
4.7.0), so matching on the constants would never fire.
Addressed from review:
- Status precedence was backwards. The provider mappers synthesize a status
when they cannot read one off the body (CustomLlmErrorMessage defaults to
400, OpenAiErrorMessage to 500), and preferring the mapped code let a
synthetic 400 mask a real upstream 503 -- classifying a transient failure as
permanent and dropping it on first delivery. The cause-chain HttpException
now wins, with the mapped code as fallback, matching the precedence
findProviderHttpStatus already documents for its own chain walk.
- Sibling aggregation could discard retryable work. The trace-thread scorers
re-emit one error for a message that fans out over many thread ids, and
errors.getFirst() made that an arrival-order race. Harmless while every
failure was a blanket 500; not once permanent and transient were split, as a
ClientErrorException arriving first would ack and remove the entry with its
retryable siblings. Both scorers now share representativeError(), which
prefers a retryable sibling: a bounded replay is recoverable, silently
dropped work is not.
- Test-only: unconditional assertion flow in the parameterized status test,
real-mapper-path coverage for the precedence rule, display-name wording.
Tests: 145 green across the affected suites. Mutation-checked -- collapsing
the status split to the whole 4xx family fails 5, removing it fails 7,
reverting the cursor to always-MIN fails 3, inverting the status precedence
fails 4, reverting aggregation to getFirst() fails 1.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>1 parent 4ef186c commit 2b96045
9 files changed
Lines changed: 582 additions & 28 deletions
File tree
- apps/opik-backend/src
- main/java/com/comet/opik
- api/resources/v1/events
- domain/llm
- test/java/com/comet/opik
- api/resources/v1/events
- domain/llm
Lines changed: 57 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
127 | 127 | | |
128 | 128 | | |
129 | 129 | | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
130 | 151 | | |
131 | 152 | | |
132 | 153 | | |
| |||
398 | 419 | | |
399 | 420 | | |
400 | 421 | | |
401 | | - | |
| 422 | + | |
402 | 423 | | |
403 | 424 | | |
404 | 425 | | |
405 | | - | |
| 426 | + | |
406 | 427 | | |
407 | 428 | | |
408 | 429 | | |
| |||
412 | 433 | | |
413 | 434 | | |
414 | 435 | | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
415 | 439 | | |
| 440 | + | |
416 | 441 | | |
417 | 442 | | |
418 | 443 | | |
419 | 444 | | |
420 | 445 | | |
421 | 446 | | |
422 | 447 | | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
423 | 478 | | |
424 | 479 | | |
425 | 480 | | |
| |||
Lines changed: 29 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
| |||
154 | 155 | | |
155 | 156 | | |
156 | 157 | | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
157 | 186 | | |
158 | 187 | | |
159 | 188 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
127 | | - | |
| 127 | + | |
128 | 128 | | |
129 | 129 | | |
130 | 130 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
116 | 116 | | |
117 | 117 | | |
118 | 118 | | |
119 | | - | |
| 119 | + | |
120 | 120 | | |
121 | 121 | | |
122 | 122 | | |
| |||
Lines changed: 60 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| 39 | + | |
39 | 40 | | |
40 | 41 | | |
41 | 42 | | |
| |||
147 | 148 | | |
148 | 149 | | |
149 | 150 | | |
150 | | - | |
151 | | - | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
152 | 168 | | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | 169 | | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
160 | 183 | | |
161 | 184 | | |
162 | 185 | | |
| |||
292 | 315 | | |
293 | 316 | | |
294 | 317 | | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
295 | 347 | | |
296 | 348 | | |
297 | 349 | | |
| |||
Lines changed: 44 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 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 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
0 commit comments