I have a rails app and a separate druby process. This process gives me some methods, and at the first line of each druby's method there is a call to ActiveRecord::Base.establish_connection, where the db_name depends on a param set by the rails application. Sometimes the process is getting the wrong database name and I think it could be a concurrency problem. Could it be? Any idea on how to make it thread-safe?
Thanks for any help! Roberto
Yes, this is a concurrency problem.
To fix it, you would have to change your architecture a little bit, but I don't have enough informations.
Basically, if you have a small and fixed number of databases, the simplest is to use different ruby processes.
If you have different databases with different models, you could envisions to use different base classes:
Then you can call
to different databases.