Iñaki Baz Castillo <[email protected]> wrote: > El Sábado, 6 de Febrero de 2010, Warren Konkel escribió: > > Could it be that class attributes are somehow being co-mingled when > > unicorn is starting up under high concurrency? Perhaps a mutex is > > missing somewhere? > > IMHO all your Unicorn workers are sharing the same DB connection (the same > ActiveRecord instances) so the problem arises. > > Take a look to the configuration here: > http://unicorn.bogomips.org/examples/unicorn.conf.rb > You can see there how the ActiveRecord is disconnected at the beggining and > started for each worker later.
Yes, you have to reconnect any connected TCP sockets since they have no defined atomicity semantics when they're shared across processes/threads. Ruby Mutexes aren't useful at all here, they're only useful with threads in the same process. If you need to protect TCP client sockets from multiple processes, you'll need SysV/POSIX semaphores or file locks (flock/fcntl), but you're really better off using multiple TCP client sockets in the first place. -- Eric Wong _______________________________________________ Unicorn mailing list - [email protected] http://rubyforge.org/mailman/listinfo/mongrel-unicorn Do not quote signatures (like this one) or top post when replying
