This project is archived and is in readonly mode.

#844 ✓wontfix
Kris Rasmussen

threadsafe! in ActiveSupport::Cache::Store extends all instances of the class, and breaking all but the one it was called on

Reported by Kris Rasmussen | August 16th, 2008 @ 01:40 AM | in 2.x

When you call threadsafe! on an instance of ActiveSupport::Cache::Store it extends the class with the ThreadSafe module, thus effecting all future instances, not just the current instance.

I don't think this is the desired behavior, but either way it ends up breaking all future instances because the @mutex instance variable will be null for them.

Instead, I think the author meant to "extend" the instance of the class with the ThreadSafe module.

Here is a monkey patch that does this:

module ActiveSupport module Cache

class Store
  def threadsafe!
    @mutex =
    self.extend ThreadSafety

end end

It appears that edge rails assumes all caches (except memory cache) are thread safe by default and so this is no longer an issue.

Comments and changes to this ticket

  • josh

    josh November 16th, 2008 @ 06:59 PM

    • State changed from “new” to “wontfix”

    Yeah, the memory store is the only issue so we have SynchronizedMemoryStore now.

  • Kris Rasmussen

    Kris Rasmussen November 17th, 2008 @ 05:43 AM

    Hi Josh,

    Thanks for getting back to me on this. You may have fixed this in one of the later commits, but the default memcached library did not appear to be thread-safe to me. I had to extend it with the ThreadSafety module to get things to work reliably.

    Thanks, Kris

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href=""></a>

People watching this ticket