Repository navigation
fix(state): persist cancelled redis handler updates - #7412
Conversation
[Medium impact] The PR appears safe to merge; no new actionable issue was found. SummaryPreserves Redis state changes when foreground handlers fail or are cancelled.
The earlier repeated-cancellation finding is addressed: another cancellation no longer interrupts the separate save task. Reviews (5) · Last reviewed commit: "fix(state): keep redis writes of handler..." · Reviewed by Greptile |
Merging this PR will improve performance by 4.49%1 warning
Performance Changes
Tip Curious why performance improved? Comment Comparing |
A handler exception dropped its writes on the non-cached Redis paths, while memory, disk and the Redis cached-lease path keep them. Save on any handler exception, not only on cancellation, so every path matches. Document that a write after the last yield reaches the frontend only with a later update on Redis.
|
I pushed two commits to this branch.
Why the second change: on Redis, a handler exception dropped its writes on the non-cached paths. Memory, disk and the Redis cached-lease path keep them. So the result depended on whether a lease was cached. The docs now also say that on Redis, a write made after the last If the lock expired, the fenced save writes nothing and raises |
Summary
Fixes #7248.
When a foreground handler is cancelled by a superseding event, Redis can discard every state change it made before cancellation, including updates already yielded to the client. The replacement handler then reads the old state. Preserve those changes before releasing the Redis lock so the replacement sees the same history as it does with in-memory state.
What changed
Verification
uv run pytest tests/units --cov --no-cov-on-fail --cov-report=: 11,193 passed, 155 skipped; 78.68% coverage.uv run ruff check .,uv run ruff format --check .anduv run pyright reflex testspassed.--pythonplatform Linux, matching CI. The remainingtyand Biome hooks passed separately.