resque-status icon indicating copy to clipboard operation
resque-status copied to clipboard

Resque::Plugins::Status::Hash.statuses fails large number of statuses

Open akshaymankar opened this issue 10 years ago • 4 comments

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

akshaymankar avatar Jun 30 '15 18:06 akshaymankar

Hey @akshaymankar

Do you have the solution? I have the same issue.

jyr avatar Sep 23 '15 21:09 jyr

@jyr You can change ulimit to increase stack size to get around it. But I don't really have a solution :disappointed:

akshaymankar avatar Sep 30 '15 09:09 akshaymankar

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

geoffyoungs avatar Aug 13 '20 16:08 geoffyoungs

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?

chowells79 avatar Mar 07 '22 23:03 chowells79