In my app, for three models: foo,bar and baz, the database connection
is made to a different database and hence in model code:
class Foo < ActiveRecord::Base
establish_connection :diff_database
end
class Bar < ActiveRecord::Base
establish_connection :diff_database
end
class Baz < ActiveRecord::Base
establish_connection :diff_database
end
Now, the problem is, if is use the above code, not one but three
connections to another database is made and it seems that number of
connections made to the database keeps rising.
The mysql forks a new process for handling each new connection and
following shell command reports a rising number of forked processes.
ps ax|grep mysql|egrep ‘local’|wc -l
And eventually when number of forked processes touches > 35, then i
get error, Mysql::Error too many connections open.
Now, I must use these three tables from old database because of some
datab constraints, so what are my options here?
Any pointers would be appreciated.
–
There was only one Road; that it was like a great river: its springs
were at every doorstep, and every path was its tributary.