Dalli and Angry TypeErrors - Part 3 (SOLUTION)
Continuation to Dalli and Angry TypeErrors - Part 2
And the answer arrives in the form of: another tumblr post. Awesome. Had to Google some longtail keywords to find it, however, so hoping these three blogposts can help lost souls quicker.
Clue #1: http://www.modrails.com/documentation/Users%20guide%20Nginx.html#spawning_methods_explained
This is mod_rails, aka Passenger by Phusion documentation. Read about spawning methods. See one that’s all too similar to Unicorn’s? Oh, what’s that, a gotcha? Read it.
Clue #2: http://petelacey.tumblr.com/post/3073967460/on-forking-application-servers-and-memcached-in-rails
tl;dr
Forked Unicorns will share the memcached connection socket and will therefore interfere with each other’s commands. This obviously become a bigger problem under load.
Solution?
after_fork do |server, worker|
# existing code in your block
# reset the memcached connection, this method call is valid for Dalli only!
Rails.cache.reset
end
Voila. Enjoy TypeError free redeployments.