nkallen / cache-money

A Write-Through Cacheing Library for ActiveRecord
Apache License 2.0
994 stars 107 forks source link

Is cache-money threadsafe? #24

Open bpardee opened 14 years ago

bpardee commented 14 years ago

I ask because we're converting an MRI app to JRuby and I got the following error which looks like a possible race condition:

undefined method pop' for <MemCache: 1 servers, ns: nil, ro: false>:MemCache [RAILS_ROOT]/vendor/gems/nkallen-cache-money-0.2.5/lib/cash/local.rb:17:inmethod_missing'

RAILS_ROOT]/vendor/gems/nkallen-cache-money-0.2.5/lib/cash/local.rb:17:in method_missing' [RAILS_ROOT]/vendor/gems/nkallen-cache-money-0.2.5/lib/cash/transactional.rb:39:inend_transaction' [RAILS_ROOT]/vendor/gems/nkallen-cache-money-0.2.5/lib/cash/transactional.rb:19:in transaction' [RAILS_ROOT]/vendor/gems/nkallen-cache-money-0.2.5/lib/cache_money.rb:58:intransaction_with_cache_transaction' [RAILS_ROOT]/vendor/rails/activerecord/lib/active_record/transactions.rb:228:in with_transaction_returning_status' [RAILS_ROOT]/vendor/rails/activerecord/lib/active_record/transactions.rb:196:insave_with_transactions' [RAILS_ROOT]/vendor/rails/activerecord/lib/active_record/transactions.rb:208:in rollback_active_record_state!' [RAILS_ROOT]/vendor/rails/activerecord/lib/active_record/transactions.rb:196:insave_with_transactions' [RAILS_ROOT]/vendor/plugins/active_scaffold/lib/extensions/unsaved_record.rb:15:in `save_with_unsaved_flag'

It looks like an extra end_transaction was called without a matching begin_transaction?

d01 commented 12 years ago

Sorry to bump this musty bug, but we are in the same boat with a different error - bpardee, did you ultimately have to ditch cache_money in your JRuby move?

bpardee commented 12 years ago

Yes, we no longer use it.

On Sat, Nov 26, 2011 at 3:43 PM, d01 < reply@reply.github.com

wrote:

Sorry to bump this musty bug, but we are in the same boat with a different error - bpardee, did you ultimately have to ditch cache_money in your JRuby move?


Reply to this email directly or view it on GitHub: https://github.com/nkallen/cache-money/issues/24#issuecomment-2883778

d01 commented 12 years ago

If you don't mind my asking, was it that you definitely found it wasn't threadsafe? What did you switch to?

bpardee commented 12 years ago

I can't remember if we definitively found that it wasn't threadsafe but their definitely seemed to be a problem. We moved towards explicit memcached client calls where we felt we needed them and put more thought into what we were caching. For instance instead of caching all the individual rows of data about a client we would cache it in one call since they typically would load all that data anyways.

On Sat, Nov 26, 2011 at 9:09 PM, d01 < reply@reply.github.com

wrote:

If you don't mind my asking, was it that you definitely found it wasn't threadsafe? What did you switch to?


Reply to this email directly or view it on GitHub: https://github.com/nkallen/cache-money/issues/24#issuecomment-2885254

d01 commented 12 years ago

Thank you.

It's not good news in the short run, but I will be relieved to be ditching cache_money. It does appear to have worked, but it's one of the least documented, least maintained things I've ever been foolish enough to put into production, and it's just as well that I finally have to rip the bandaid off.