Commit 00525f7
fix(tracing): harden offline buffer for concurrency and high volume
The offline buffer could lose or over-retain data under multi-process and
high-volume use. Fixes mirror the openlayer-ts SDK:
- store_trace: evict in a batch down to max_buffer_size instead of dropping
a single file per call, so the cap holds even when multiple processes
share the buffer directory and evict concurrently. Stat each candidate
defensively so a file removed by another writer mid-scan doesn't abort
the store (which previously dropped the trace).
- Use the full UUID in filenames instead of an 8-char slice; worker threads
share a PID, so a truncated id could collide and silently overwrite a
buffered trace at high volume.
- max_buffer_size=0 is now honored (store nothing) instead of being
coerced to the 1000 default by 'or'.
- clear_buffer isolates each removal so one failure no longer aborts the
rest, and returns the count actually removed.
- replay_buffered_traces always attempts each trace at least once, so
max_retries=0 is no longer a silent no-op.
Adds regression tests (each verified to fail on the prior implementation).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 88891a0 commit 00525f7
2 files changed
Lines changed: 112 additions & 18 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
384 | 384 | | |
385 | 385 | | |
386 | 386 | | |
387 | | - | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
388 | 390 | | |
389 | 391 | | |
390 | 392 | | |
| |||
408 | 410 | | |
409 | 411 | | |
410 | 412 | | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
411 | 416 | | |
412 | 417 | | |
413 | | - | |
414 | | - | |
415 | | - | |
416 | | - | |
417 | | - | |
418 | | - | |
419 | | - | |
420 | | - | |
421 | | - | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
422 | 446 | | |
423 | | - | |
| 447 | + | |
424 | 448 | | |
425 | 449 | | |
426 | 450 | | |
| |||
534 | 558 | | |
535 | 559 | | |
536 | 560 | | |
| 561 | + | |
537 | 562 | | |
538 | 563 | | |
539 | 564 | | |
540 | | - | |
541 | 565 | | |
542 | 566 | | |
543 | | - | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
544 | 574 | | |
545 | | - | |
546 | | - | |
| 575 | + | |
| 576 | + | |
547 | 577 | | |
548 | 578 | | |
549 | | - | |
| 579 | + | |
550 | 580 | | |
551 | 581 | | |
552 | 582 | | |
| |||
1622 | 1652 | | |
1623 | 1653 | | |
1624 | 1654 | | |
| 1655 | + | |
| 1656 | + | |
| 1657 | + | |
| 1658 | + | |
1625 | 1659 | | |
1626 | 1660 | | |
1627 | 1661 | | |
| |||
1640 | 1674 | | |
1641 | 1675 | | |
1642 | 1676 | | |
1643 | | - | |
| 1677 | + | |
1644 | 1678 | | |
1645 | 1679 | | |
1646 | 1680 | | |
| |||
1680 | 1714 | | |
1681 | 1715 | | |
1682 | 1716 | | |
1683 | | - | |
| 1717 | + | |
1684 | 1718 | | |
1685 | 1719 | | |
1686 | 1720 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
153 | 153 | | |
154 | 154 | | |
155 | 155 | | |
| 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 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
156 | 194 | | |
157 | 195 | | |
158 | 196 | | |
| |||
421 | 459 | | |
422 | 460 | | |
423 | 461 | | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
424 | 484 | | |
425 | 485 | | |
426 | 486 | | |
| |||
0 commit comments