Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
akshaymankar opened this issue Jun 30, 2015 · 4 comments
Open

Comments

@akshaymankar
Copy link

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

@jyr
Copy link

jyr commented Sep 23, 2015

Hey @akshaymankar

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

@akshaymankar
Copy link
Author

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

@geoffyoungs
Copy link

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

@chowells79
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants