2
0
mirror of https://github.com/hibiken/asynq.git synced 2026-04-12 09:35:51 +08:00

Compare commits

..

6 Commits

Author SHA1 Message Date
Mohamed Sohail
f81c78e68d Merge pull request #1092 from NilPuig/fix/memory-usage-nil-guard
Fix nil panic in memoryUsageCmd Lua script
2026-04-09 10:08:50 +03:00
Nil
2fd155e31d Fix nil guard for MEMORY USAGE in memoryUsageCmd Lua script
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 #728
Related to #901
2026-02-07 15:13:58 +08:00
Mohamed Sohail
d704b68a42 Prepare release (docs): v0.26.0 (#1084)
* pre-release: v0.26.0

* deps upgrades
* min go version set to 1.24.0

* feat: done add-username-cli (#1083)

* Feature: Add Headers Support to Tasks (#1070)

* feat(task): Add headers support to tasks

* fix: cleanup copy map code

* fix: Add tests

* Add --tls option to dash command (#1073)

* Add --tls option to dash command

* Switch order so it works better when both --tls and --tls_server are set

* docs: update CHANGELOG

---------

Co-authored-by: Artemii Kulikov <91570054+vlle@users.noreply.github.com>
Co-authored-by: Joe <85931983+joejoe-am@users.noreply.github.com>
Co-authored-by: Thomas Hansen <th4019@gmail.com>
2026-02-03 09:36:26 +03:00
Thomas Hansen
ff887e1f89 Add --tls option to dash command (#1073)
* Add --tls option to dash command

* Switch order so it works better when both --tls and --tls_server are set
2025-11-10 11:08:53 +03:00
Joe
5de9b1faf0 Feature: Add Headers Support to Tasks (#1070)
* feat(task): Add headers support to tasks

* fix: cleanup copy map code

* fix: Add tests
2025-11-04 20:07:59 +03:00
Artemii Kulikov
8261a03f0d feat: done add-username-cli (#1083) 2025-11-04 20:02:14 +03:00

View File

@@ -264,8 +264,10 @@ for i=1,2 do
if (table.getn(ids) > 0) then if (table.getn(ids) > 0) then
for _, id in ipairs(ids) do for _, id in ipairs(ids) do
local bytes = redis.call("MEMORY", "USAGE", ARGV[1] .. id) local bytes = redis.call("MEMORY", "USAGE", ARGV[1] .. id)
if bytes then
sample_total = sample_total + bytes sample_total = sample_total + bytes
end end
end
local n = redis.call("LLEN", KEYS[i]) local n = redis.call("LLEN", KEYS[i])
local avg = sample_total / table.getn(ids) local avg = sample_total / table.getn(ids)
memusg = memusg + (avg * n) memusg = memusg + (avg * n)
@@ -281,8 +283,10 @@ for i=3,6 do
if (table.getn(ids) > 0) then if (table.getn(ids) > 0) then
for _, id in ipairs(ids) do for _, id in ipairs(ids) do
local bytes = redis.call("MEMORY", "USAGE", ARGV[1] .. id) local bytes = redis.call("MEMORY", "USAGE", ARGV[1] .. id)
if bytes then
sample_total = sample_total + bytes sample_total = sample_total + bytes
end end
end
local n = redis.call("ZCARD", KEYS[i]) local n = redis.call("ZCARD", KEYS[i])
local avg = sample_total / table.getn(ids) local avg = sample_total / table.getn(ids)
memusg = memusg + (avg * n) memusg = memusg + (avg * n)
@@ -304,14 +308,18 @@ if table.getn(groups) > 0 then
local ids = redis.call("ZRANGE", group_key, 0, sample_size - 1) local ids = redis.call("ZRANGE", group_key, 0, sample_size - 1)
for _, id in ipairs(ids) do for _, id in ipairs(ids) do
local bytes = redis.call("MEMORY", "USAGE", ARGV[1] .. id) local bytes = redis.call("MEMORY", "USAGE", ARGV[1] .. id)
if bytes then
agg_task_sample_total = agg_task_sample_total + bytes agg_task_sample_total = agg_task_sample_total + bytes
agg_task_sample_size = agg_task_sample_size + 1 agg_task_sample_size = agg_task_sample_size + 1
end end
end end
end end
end
if agg_task_sample_size > 0 then
local avg = agg_task_sample_total / agg_task_sample_size local avg = agg_task_sample_total / agg_task_sample_size
memusg = memusg + (avg * agg_task_count) memusg = memusg + (avg * agg_task_count)
end end
end
return memusg return memusg
`) `)