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

Digest::Base cannot be directly inherited in Ruby #45

Closed
werleo opened this issue Mar 13, 2017 · 2 comments
Closed

Digest::Base cannot be directly inherited in Ruby #45

werleo opened this issue Mar 13, 2017 · 2 comments
Assignees
Labels
Milestone

Comments

@werleo
Copy link

werleo commented Mar 13, 2017

We call aerospike in sidekiq workers which requires to have all classes thread safe.

Calling Aerospike::Key.new(arguments)

raises Digest::Base cannot be directly inherited in Ruby

1 gems/aerospike-2.3.0/lib/aerospike/key.rb" line 31 in new
2 gems/aerospike-2.3.0/lib/aerospike/key.rb" line 31 in block in <class:Key>
3 gems/aerospike-2.3.0/lib/aerospike/utils/pool.rb" line 46 in rescue in poll
4 gems/aerospike-2.3.0/lib/aerospike/utils/pool.rb" line 43 in poll
5 gems/aerospike-2.3.0/lib/aerospike/key.rb" line 117 in compute_digest
6 gems/aerospike-2.3.0/lib/aerospike/key.rb" line 61 in initialize

From ruby docs we can call Digest classes in thread safe manner:
https://docs.ruby-lang.org/en/2.2.0/Object.html#method-i-Digest

I think it should be done here:
https://github.com/aerospike/aerospike-client-ruby/blob/master/lib/aerospike/key.rb#L31

@jhecking
Copy link
Contributor

Interesting! I found similar issues raised in various other projects, e.g. for the AWS SDK or Chef. But it's not yet clear to me what the right solution is:

  • Replace usage of Digest with OpenSSL::Digest - Are there any downsides to using OpenSSL::Digest? Need to clarify why we are using Digest on MRI in the first place.
  • Use Digest(:RMD160) instead of Digest::RMD160.new - But looks like Digest() was only made thread-safe in Ruby 2.2, so might not be solving the issue in older versions of Ruby.

Will need to do a bit more research on this.

@jhecking jhecking added the bug label Mar 14, 2017
@werleo
Copy link
Author

werleo commented Mar 14, 2017

List of not thread safe gems from sidekiq wiki:

https://github.com/mperham/sidekiq/wiki/Problems-and-Troubleshooting#not-thread-safe-gems

I don't know details about OpenSSl::Digest so I am not able to help here.

We use ruby 2.3.3.

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