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

Multi-process access in Heroku environment causes PubNub initialization to occasionally fail #21

Closed
rafalyesware opened this issue Jan 14, 2014 · 7 comments

Comments

@rafalyesware
Copy link

As noted in assaf/uuid#28 and assaf/uuid#6, the UUID gem has multi-process access issues in certain environments (in our case, running push workers in Heroku via Resque or Resque-Pools).

About 2,000 times during a 24-hour period, we see the following crash of the push worker:

Exception: NoMethodError
Error: undefined method `unpack' for nil:NilClass
/app/vendor/bundle/ruby/2.0.0/gems/uuid-2.3.7/lib/uuid.rb:377:in `read_state'
/app/vendor/bundle/ruby/2.0.0/gems/uuid-2.3.7/lib/uuid.rb:333:in `block in next_sequence'
/app/vendor/bundle/ruby/2.0.0/gems/uuid-2.3.7/lib/uuid.rb:367:in `block in open_lock'
/app/vendor/bundle/ruby/2.0.0/gems/uuid-2.3.7/lib/uuid.rb:364:in `open'
/app/vendor/bundle/ruby/2.0.0/gems/uuid-2.3.7/lib/uuid.rb:364:in `open_lock'
/app/vendor/bundle/ruby/2.0.0/gems/uuid-2.3.7/lib/uuid.rb:332:in `next_sequence'
/app/vendor/bundle/ruby/2.0.0/gems/uuid-2.3.7/lib/uuid.rb:263:in `initialize'
/app/vendor/bundle/ruby/2.0.0/bundler/gems/ruby-d159a072b272/lib/pubnub/client.rb:60:in `new'
/app/vendor/bundle/ruby/2.0.0/bundler/gems/ruby-d159a072b272/lib/pubnub/client.rb:60:in `initialize'
/app/vendor/bundle/ruby/2.0.0/bundler/gems/ruby-d159a072b272/lib/pubnub.rb:57:in `new'
/app/vendor/bundle/ruby/2.0.0/bundler/gems/ruby-d159a072b272/lib/pubnub.rb:57:in `new'
/app/app/classes/send_push.rb:50:in `connection'
/app/app/classes/send_push.rb:24:in `call'
/app/app/classes/send_push.rb:15:in `call'
/app/app/workers/push_worker.rb:46:in `perform'
/app/app/workers/push_worker.rb:28:in `perform'

It would be great if the PubNub gem didn't depend on an inheretly-multi-process-unsafe gem for UUID by default (uuidtools seems like a nice alternative, SecureRandom.uuid is a possibility as well).

@blazeroot
Copy link
Contributor

Thanks for notice @rafalyesware, i'm checking it and i will apply fix asap.

@rafalyesware
Copy link
Author

Thanks @blazeroot. FWIW, all the Ruby UUID gems seem to have some failing or another... I don't know if you really need a UUID or just a large unique value, but if you can do without a proper UUID the Mongo ObjectID seems like a great choice (c.f. http://docs.mongodb.org/manual/reference/object-id/) for multi-host / multi-process environments.

@geremyCohen
Copy link
Contributor

@blazeroot FWIW, we don't need EXACTLY per the UUID-spec, just a UUID-like pattern that has an equivalent duplicates collision domain within its own alogrithm, and UUID's.

@blazeroot
Copy link
Contributor

Fixed and tested. @rafalyesware please use master branch of pubnub and let me know if that helps.
ps. SecureRandom doesn't exist in 1.8 and we want pubnub to be compatible with ruby1.8.

@rafalyesware
Copy link
Author

You guys are all right! 👍 Will try to pull this in to our code ASAP, thanks!

@rafalyesware
Copy link
Author

@blazeroot Pulled the latest gem off master and it is working as promised. Thanks for the quick turnaround!

@blazeroot
Copy link
Contributor

@rafalyesware No problem! I'm happy to hear that!

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

3 participants