Commit 3475eb7
fix(redis): keep counters outliving their data, and stop a failed fold retrying hot
The copilot owner counter used a fixed one-hour window while the stream TTL is
configurable and defaults to exactly that. Raising COPILOT_STREAM_TTL_SECONDS
would have let the counter expire under live data, and the next write would see
zero reserved and grant another full ceiling. The window is now the larger of
the two, so a counter can never expire before what it accounts for.
A failed fold deliberately leaves the trigger armed, but the snapshot XADD lands
before the XTRIM — so a persistent trim failure retried immediately, appending a
full-document snapshot every time and turning a Redis blip into the write
amplification the threshold exists to prevent. A forced fold now waits out a
cooldown after a failure. The entry-count path is unaffected.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>1 parent 2487350 commit 3475eb7
3 files changed
Lines changed: 38 additions & 2 deletions
File tree
- apps
- realtime/src/handlers
- sim/lib/copilot/request/session
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
134 | 134 | | |
135 | 135 | | |
136 | 136 | | |
| 137 | + | |
137 | 138 | | |
138 | 139 | | |
139 | 140 | | |
| |||
365 | 366 | | |
366 | 367 | | |
367 | 368 | | |
| 369 | + | |
368 | 370 | | |
369 | 371 | | |
370 | 372 | | |
| |||
507 | 509 | | |
508 | 510 | | |
509 | 511 | | |
510 | | - | |
511 | 512 | | |
512 | 513 | | |
513 | 514 | | |
514 | 515 | | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
515 | 527 | | |
516 | 528 | | |
517 | 529 | | |
| |||
557 | 569 | | |
558 | 570 | | |
559 | 571 | | |
| 572 | + | |
560 | 573 | | |
561 | 574 | | |
562 | 575 | | |
| |||
724 | 737 | | |
725 | 738 | | |
726 | 739 | | |
| 740 | + | |
727 | 741 | | |
728 | 742 | | |
729 | 743 | | |
| |||
732 | 746 | | |
733 | 747 | | |
734 | 748 | | |
| 749 | + | |
735 | 750 | | |
736 | 751 | | |
737 | 752 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
162 | 162 | | |
163 | 163 | | |
164 | 164 | | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
165 | 174 | | |
166 | 175 | | |
167 | 176 | | |
| |||
253 | 262 | | |
254 | 263 | | |
255 | 264 | | |
| 265 | + | |
| 266 | + | |
256 | 267 | | |
257 | 268 | | |
258 | 269 | | |
| |||
349 | 360 | | |
350 | 361 | | |
351 | 362 | | |
| 363 | + | |
352 | 364 | | |
353 | 365 | | |
354 | 366 | | |
| |||
804 | 816 | | |
805 | 817 | | |
806 | 818 | | |
| 819 | + | |
807 | 820 | | |
808 | 821 | | |
809 | 822 | | |
| |||
844 | 857 | | |
845 | 858 | | |
846 | 859 | | |
| 860 | + | |
847 | 861 | | |
848 | 862 | | |
849 | 863 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
260 | 260 | | |
261 | 261 | | |
262 | 262 | | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
263 | 270 | | |
264 | 271 | | |
265 | 272 | | |
| |||
321 | 328 | | |
322 | 329 | | |
323 | 330 | | |
324 | | - | |
| 331 | + | |
325 | 332 | | |
326 | 333 | | |
327 | 334 | | |
| |||
0 commit comments