Fix nil panic in memoryUsageCmd Lua script#1092
Open
NilPuig wants to merge 1 commit intohibiken:masterfrom
Open
Fix nil panic in memoryUsageCmd Lua script#1092NilPuig wants to merge 1 commit intohibiken:masterfrom
NilPuig wants to merge 1 commit intohibiken:masterfrom
Conversation
MEMORY USAGE returns nil for keys that no longer exist (e.g., expired or deleted task keys). In Lua, nil is converted to false (a boolean). The script then attempts arithmetic on this boolean value, causing: ERR user_script:30: attempt to perform arithmetic on local 'bytes' (a boolean value) This breaks the /api/queues endpoint in asynqmon, showing "Could not retrieve queues live data" in the UI. The fix adds nil guards around all three MEMORY USAGE calls on task keys, and a divide-by-zero guard on agg_task_sample_size. Tested in production with Redis 7.2 and asynq v0.25.1 worker. Fixes hibiken#728 Related to hibiken#901
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1092 +/- ##
==========================================
- Coverage 67.13% 63.34% -3.80%
==========================================
Files 29 29
Lines 4300 4984 +684
==========================================
+ Hits 2887 3157 +270
- Misses 1135 1549 +414
Partials 278 278 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
kamikazechaser
approved these changes
Feb 10, 2026
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
MEMORY USAGEreturns nil for Redis keys that no longer exist (e.g., expired or deleted task keys). In Lua, nil is converted tofalse(a boolean). ThememoryUsageCmdscript then attempts arithmetic on this boolean value, causing:This breaks
Inspector.GetQueueInfo()and the/api/queuesendpoint in asynqmon, showing "Could not retrieve queues live data" in the UI.Changes
MEMORY USAGEcalls on task keys (lines 266, 283, 306)agg_task_sample_sizefor the aggregation group sectionHow to reproduce
This happens when task keys referenced in a queue's pending/active/scheduled/retry lists have expired or been deleted from Redis, but the list entries still reference them.
MEMORY USAGEon a non-existent key returns nil, which becomesfalsein Lua.Testing
Tested in production with Redis 7.2.4 and asynq v0.25.1 worker processing ~900K tasks/day. After applying this patch, the
/api/queuesendpoint returns data correctly.Fixes #728
Related to #901