Commit 4db754f
authored
## Summary
Follow-up to merged PR #620, addressing the [Gemini medium-priority
review](#620 (review))
that landed after the merge. Three changes, all with regression tests:
- `safeUnixMilliToUint64` defends `nextXAddID`'s `*` branch against a
system clock set before the Unix epoch (a negative `UnixMilli` would
wrap to a `math.MaxUint64`-adjacent value and wedge every subsequent
`XADD '*'` chasing that pathological future-ms).
- `xread`'s `$`-resolve and `xreadBusyPoll`'s per-iteration ctx now
derive from `r.handlerContext()` instead of `context.Background()`, so a
server `Close()` aborts in-flight BLOCK XREADs within ~one
`redisBusyPollBackoff` (10 ms) instead of running until the BLOCK
deadline. The busy-poll loop also short-circuits at the top of each
iteration when `handlerCtx` is cancelled — necessary because
`isXReadIterCtxError` would otherwise silently translate the
per-iteration cancel into "empty iteration" and let the loop spin at
backoff cadence.
- `resolveXReadDollarID`'s doc comment said "legacy blobs fall back to a
full load"; PR #620 deliberately removed that fallback in favour of the
"discard-on-read, delete-on-write" contract. Comment now matches the
implementation.
## Test plan
- [x] `TestSafeUnixMilliToUint64` (unit) — clamp-at-0 for negatives
(`-1`, large negative, `MinInt64`); pass-through for `0`, positive,
`MaxInt64`.
- [x] `TestRedis_StreamXReadShutdownShortCircuits` (e2e) — `XREAD ...
BLOCK 5s` in a goroutine, `redisServer.Close()` after 50 ms, assert
reply is `redis.Nil` within 2 s.
- [x] Build / vet / lint clean.
- [x] Existing `TestRedis_StreamXReadShortBlockReturnsNullNotError` and
`TestRedis_StreamXReadIterCtxDeadlineReturnsNull` still pass — the
shutdown short-circuit doesn't perturb the existing
BLOCK-timeout-returns-null path.
/gemini review
@codex review
3 files changed
Lines changed: 224 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3702 | 3702 | | |
3703 | 3703 | | |
3704 | 3704 | | |
| 3705 | + | |
| 3706 | + | |
3705 | 3707 | | |
3706 | | - | |
| 3708 | + | |
| 3709 | + | |
| 3710 | + | |
| 3711 | + | |
| 3712 | + | |
| 3713 | + | |
| 3714 | + | |
| 3715 | + | |
| 3716 | + | |
| 3717 | + | |
| 3718 | + | |
| 3719 | + | |
| 3720 | + | |
| 3721 | + | |
| 3722 | + | |
| 3723 | + | |
| 3724 | + | |
| 3725 | + | |
| 3726 | + | |
3707 | 3727 | | |
3708 | | - | |
| 3728 | + | |
| 3729 | + | |
| 3730 | + | |
| 3731 | + | |
| 3732 | + | |
3709 | 3733 | | |
3710 | 3734 | | |
3711 | 3735 | | |
| |||
3718 | 3742 | | |
3719 | 3743 | | |
3720 | 3744 | | |
| 3745 | + | |
| 3746 | + | |
| 3747 | + | |
| 3748 | + | |
| 3749 | + | |
| 3750 | + | |
| 3751 | + | |
| 3752 | + | |
| 3753 | + | |
| 3754 | + | |
| 3755 | + | |
| 3756 | + | |
| 3757 | + | |
| 3758 | + | |
| 3759 | + | |
3721 | 3760 | | |
3722 | 3761 | | |
3723 | 3762 | | |
| |||
4305 | 4344 | | |
4306 | 4345 | | |
4307 | 4346 | | |
4308 | | - | |
4309 | | - | |
4310 | | - | |
4311 | | - | |
4312 | | - | |
| 4347 | + | |
| 4348 | + | |
| 4349 | + | |
| 4350 | + | |
| 4351 | + | |
| 4352 | + | |
| 4353 | + | |
| 4354 | + | |
4313 | 4355 | | |
4314 | 4356 | | |
4315 | 4357 | | |
| |||
4567 | 4609 | | |
4568 | 4610 | | |
4569 | 4611 | | |
4570 | | - | |
| 4612 | + | |
| 4613 | + | |
| 4614 | + | |
| 4615 | + | |
| 4616 | + | |
| 4617 | + | |
4571 | 4618 | | |
4572 | 4619 | | |
4573 | 4620 | | |
| |||
4581 | 4628 | | |
4582 | 4629 | | |
4583 | 4630 | | |
| 4631 | + | |
4584 | 4632 | | |
| 4633 | + | |
| 4634 | + | |
| 4635 | + | |
| 4636 | + | |
| 4637 | + | |
| 4638 | + | |
| 4639 | + | |
| 4640 | + | |
| 4641 | + | |
| 4642 | + | |
| 4643 | + | |
4585 | 4644 | | |
4586 | 4645 | | |
4587 | 4646 | | |
| |||
4598 | 4657 | | |
4599 | 4658 | | |
4600 | 4659 | | |
4601 | | - | |
| 4660 | + | |
| 4661 | + | |
| 4662 | + | |
| 4663 | + | |
| 4664 | + | |
| 4665 | + | |
4602 | 4666 | | |
4603 | 4667 | | |
4604 | 4668 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
763 | 763 | | |
764 | 764 | | |
765 | 765 | | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
304 | 304 | | |
305 | 305 | | |
306 | 306 | | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 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 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
0 commit comments