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

redis_key does not return unique key #26

Open
stcheung opened this issue Jan 15, 2013 · 1 comment
Open

redis_key does not return unique key #26

stcheung opened this issue Jan 15, 2013 · 1 comment
Labels

Comments

@stcheung
Copy link

I am relying on the default redis_key method in the 1.2.1 version to produce a unique key when the args is the same. In my case, the args is simply a single numeric id, such as 347. Poking into the code I realized that redis_key returns "Digest::MD5.hexdigest encode(:class => job, :args => args)". The problem with this is that the encode method would return a string where sometimes the :args parameter comes first, and sometimes the :class parameter comes first:

(1) "{"args":[347],"class""AsyncCallback"}"
(2) "{"class""AsyncCallback", "args":[347]}"

I can only reproduce it on a staging server (but not on development). Furthermore, within the same rails console I will always get the same version back. But when I restart the console then usually I can see the other version being returned. It seems to alternate but even if not, I can usually get the other version within a few console restarts.

I am using ruby 1.8.7 and Rails 3.0.19. I can overwrite the redis_key method in my class but I wonder if this is a generic issue that should be fixed in the plugin itself. Thanks.

@stcheung
Copy link
Author

Upon further inspection and experimentation I realized it's because ultimately we are calling the "to_json" method on the hash and since 1.8.7 doesn't guarantee the key ordering, the resulting string can look different due to a different ordering of the keys.

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

No branches or pull requests

2 participants