Resque::Plugins::Status::Hash.statuses fails large number of statuses
It tries to splat all the status keys and causes a stack level too deep error. Here: https://github.com/quirkey/resque-status/blob/master/lib/resque/plugins/status/hash.rb#L31
Hey @akshaymankar
Do you have the solution? I have the same issue.
@jyr You can change ulimit to increase stack size to get around it. But I don't really have a solution :disappointed:
In case anyone else is still looking at this, we use the following:
module MonkeyPatches
module ResqueStatus
module Hash
def self.prepended(base)
base.singleton_class.prepend(ClassMethods)
end
MGET_BATCH_SIZE = 100
module ClassMethods
# Get multiple statuses by UUID. Returns array of Resque::Plugins::Status::Hash
def mget(uuids)
return [] if uuids.empty?
# `mget(uuids)` calls `redis.mget(*status_keys)` that, due to the splat,
# can fail with large list (limit currently unknown), so batch them
uuids.
each_slice(MGET_BATCH_SIZE).
inject([]) do |fetched, slice_of_uuids|
fetched_slice = super(slice_of_uuids) || []
fetched.concat(fetched_slice)
end
end
end
end
end
end
Resque::Plugins::Status::Hash.prepend MonkeyPatches::ResqueStatus::Hash
This can be fixed by just removing the * in https://github.com/quirkey/resque-status/blob/master/lib/resque/plugins/status/hash.rb#L31 . mget is perfectly happy taking a list as an argument. Also, this has been an issue for nearly 7 years now. Can we maybe get a release that just removes that * to fix this?