Fix WRONGTYPE error and add memory leak detection tests#153
Merged
chrisguidry merged 1 commit intomainfrom Aug 18, 2025
Merged
Conversation
Fixes a Redis WRONGTYPE error that occurred when the worker scheduler tried to HSET on known task keys that existed as strings from legacy implementations. The error happened because we were redundantly storing stream message IDs in known task keys - this wasn't needed for the cancellation functionality to work. Also adds systematic Redis key counting tests that can detect memory leaks by comparing key counts before and after task operations. These tests cover successful tasks, failed tasks, and cancelled tasks to ensure proper cleanup in all scenarios. Changes: - Remove redundant HSET of stream_message_id in worker scheduler script - Add comprehensive memory leak detection tests with KeyCountChecker helper - Hoist all imports to top of test file per code style guidelines - Add regression test for the original WRONGTYPE error scenario 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
|
📚 Documentation has been built for this PR! You can download the documentation directly here: |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #153 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 31 31
Lines 4411 4495 +84
Branches 244 246 +2
=========================================
+ Hits 4411 4495 +84
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Merged
chrisguidry
added a commit
that referenced
this pull request
Aug 18, 2025
These fixes seem to get at least one of my systems into a state where it's infinitely looping on perpetual tasks. This may have been due to some of the intermediate problems in 0.9.0 and 0.9.1, but I don't want to take that chance. We'll come back and revisit this. This reverts commit 85f293c. Revert "Fix WRONGTYPE error and add memory leak detection tests (#153)" This reverts commit c2b8187. Revert "Fix race condition in task replacement where duplicate executions occur (#151)" This reverts commit 9dc405c.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
What was the problem?
The error occurred because we were redundantly storing stream message IDs in known task keys - this wasn't needed for the cancellation functionality to work. When legacy docket versions created known task keys as simple string values, the new scheduler would fail trying to HSET on those string keys.
What changed?
Test plan
The new tests systematically verify that Redis keys are properly cleaned up in all scenarios and can detect memory leaks by counting keys before and after operations. We validated the tests work by temporarily introducing bugs and confirming they catch the issues.
🤖 Generated with Claude Code