fix(redis): key oplock cached states by token.cache_key
VI
2d ago+125+125+012345678901234567890123456789-7-7-0123456789
Closes #8067.
All Submissions:
- Have you followed the guidelines stated in CONTRIBUTING.md file?
- Have you checked to ensure there aren't any other open Pull Requests for the desired changed?
Type of change
- Bug fix (non-breaking change which fixes an issue)
Changes To Core Features:
- Have you added an explanation of what your changes do and why you'd like us to include them?
- Have you written new tests for your core changes, as applicable?
- Have you successfully ran tests with your changes locally?
Summary
- Key
StateManagerRedis._cached_statesbytoken.cache_keyinstead oftoken.lock_keyin_get_state_cached,_create_lease_break_task, and_Lease._write_back, matchingStateManagerMemoryandStateManagerDisk. - When an active local lease on
token.lock_keyholds a differentcache_key,_get_state_cachedcancels and awaits that lease so the caller breaks/flushes it immediately rather than spinning onOplockFoundin_wait_lockuntiloplock_hold_time_msexpires. - Add regression tests in
tests/units/istate/manager/test_redis.pycovering sequential and concurrentStateTokenclasses plusBaseStateTokensharing anident, and addnews/+8067-redis-oplock-cache-key.bugfix.md.
Validation
uv run pytest tests/units/istate -q: 303 passeduv run ruff check reflex/istate/manager/redis.py tests/units/istate/manager/test_redis.py: passeduv run ruff format --check reflex/istate/manager/redis.py tests/units/istate/manager/test_redis.py: passeduv run pyright reflex/istate/manager/redis.py tests/units/istate/manager/test_redis.py: 0 errors, 0 warningsuv run reflex-release changelog-check&uv run reflex-release check-headings: passed