Skip to content

fix: resolve async implementation bugs and race conditions#26

Merged
27Bslash6 merged 1 commit intomainfrom
fix/async-implementation-bugs
Dec 17, 2025
Merged

fix: resolve async implementation bugs and race conditions#26
27Bslash6 merged 1 commit intomainfrom
fix/async-implementation-bugs

Conversation

@27Bslash6
Copy link
Contributor

Summary

  • Fix async pool race conditions in Redis client with double-checked locking to prevent multiple pool creation
  • Add proper async pool disconnect handling in reset_global_pool() when event loop is running
  • Fix missing correlation ID cleanup in async wrapper finally block (line 1247)
  • Update async operations to run in thread pool to avoid blocking event loop
  • Add comprehensive async context leak regression tests
  • Update documentation to reflect native async support with code examples

Changes

  • Redis Client: Fixed race conditions in get_async_redis_client() with asyncio.Lock
  • Pool Management: Proper disconnect handling in reset_global_pool()
  • Async Wrapper: Added missing features.clear_correlation_id() in finally block
  • Cache Handler: Modified async methods to run sync operations in thread pool
  • Documentation: Updated comparison.md with async support examples and evidence
  • Tests: Added extensive async context leak and pool lifecycle tests

Testing

  • 50+ async tests validate full async support including L1/L2 caching, circuit breaker, and distributed locking
  • Added concurrent async operation tests to verify no race conditions
  • Added context leak regression tests for both success and failure paths

Resolves multiple async stability issues identified in production testing.

@codecov
Copy link

codecov bot commented Dec 17, 2025

Codecov Report

❌ Patch coverage is 41.02564% with 23 lines in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/cachekit/backends/redis/client.py 36.84% 12 Missing ⚠️
src/cachekit/decorators/wrapper.py 20.00% 8 Missing ⚠️
src/cachekit/cache_handler.py 70.00% 2 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@27Bslash6 27Bslash6 force-pushed the fix/async-implementation-bugs branch 2 times, most recently from 70758c7 to 8bbee7f Compare December 17, 2025 05:46
- Fix async pool race conditions in Redis client with double-checked locking
- Add proper async pool disconnect handling in reset_global_pool()
- Fix missing correlation ID cleanup in async wrapper finally block
- Update async operations to run in thread pool to avoid blocking event loop
- Add comprehensive async context leak regression tests
- Update documentation to reflect native async support

Resolves multiple async stability issues identified in production testing.
@27Bslash6 27Bslash6 force-pushed the fix/async-implementation-bugs branch from 8bbee7f to dd3f34a Compare December 17, 2025 08:53
@27Bslash6 27Bslash6 merged commit f75477a into main Dec 17, 2025
36 of 37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant