fix(redis): key oplock cached states by token.cache_key

VI
2d ago
+125-7

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_states by token.cache_key instead of token.lock_key in _get_state_cached, _create_lease_break_task, and _Lease._write_back, matching StateManagerMemory and StateManagerDisk.
  • When an active local lease on token.lock_key holds a different cache_key, _get_state_cached cancels and awaits that lease so the caller breaks/flushes it immediately rather than spinning on OplockFound in _wait_lock until oplock_hold_time_ms expires.
  • Add regression tests in tests/units/istate/manager/test_redis.py covering sequential and concurrent StateToken classes plus BaseStateToken sharing an ident, and add news/+8067-redis-oplock-cache-key.bugfix.md.

Validation

  • uv run pytest tests/units/istate -q: 303 passed
  • uv run ruff check reflex/istate/manager/redis.py tests/units/istate/manager/test_redis.py: passed
  • uv run ruff format --check reflex/istate/manager/redis.py tests/units/istate/manager/test_redis.py: passed
  • uv run pyright reflex/istate/manager/redis.py tests/units/istate/manager/test_redis.py: 0 errors, 0 warnings
  • uv run reflex-release changelog-check & uv run reflex-release check-headings: passed