Hi!
I have written a XMLRPC server that which has handlers that do postgresql db queries using models (ActiveRecord::Base I guess).
Each request to my server seems to allocate one connection that are never release. Eventually I get "too many open files" and the server crashes.
- How can I make it release the connection (or at least dont setup new when there exists one)???
- I also found this: http://dev.rubyonrails.org/ticket/7105
Any related?
- Any ideas?
Thanks /Rick
Here is what I do and what I get:
SupportServer.rb (main script)
----------------------------------------
MyModel.establish_connection(db_info_hash)
...
s.add_handler("control", ControlXmlrpcHandler.new)
s.serve
----------------------------------------
Each handle uses MyModel.find_by_sql(...)
Error message, after ~250 XMLRPC calls from client:
-------------------------------------------
Too many open files
/usr/local/lib/ruby/gems/1.8/gems/postgres-pr-0.4.0/lib/postgres-pr/connection.rb:138:in `initialize'/usr/local/lib/ruby/gems/1.8/gems/postgres-pr-0.4.0/lib/postgres-pr/connection.rb:138:in `establish_connection'/usr/local/lib/ruby/gems/1.8/gems/postgres-pr-0.4.0/lib/postgres-pr/connection.rb:25:in `initialize'/usr/local/lib/ruby/gems/1.8/gems/postgres-pr-0.4.0/lib/postgres-pr/postgres-compat.rb:23:in `initialize'/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/connection_adapters/postgresql_adapter.rb:24:in `postgresql_connection'/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:145:in `connection_without_query_cache='/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/query_cache.rb:54:in `connection='/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:106:in `retrieve_connection'/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:20:in `connection'/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/base.rb:431:in `find_by_sql'./lib/cup_xmlrpc_handler.rb:119:in `cup_query'./lib/cup/cup_nodeinfo.rb:45:in `check_cellosupport'./lib/cup_xmlrpc_handler.rb:56:in `xml_request'/usr/local/lib/ruby/1.8/xmlrpc/server.rb:334:in `dispatch'/usr/local/lib/ruby/1.8/xmlrpc/server.rb:323:in `dispatch'/usr/local/lib/ruby/1.8/xmlrpc/server.rb:366:in `call_method'/usr/local/lib/ruby/1.8/xmlrpc/server.rb:378:in `handle'/usr/local/lib/ruby/1.8/xmlrpc/server.rb:310:in `process'/usr/local/lib/ruby/1.8/xmlrpc/server.rb:760:in `service'/usr/local/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'/usr/local/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'/usr/local/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'/usr/local/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'/usr/local/lib/ruby/1.8/webrick/server.rb:95:in `start'/usr/local/lib/ruby/1.8/webrick/server.rb:92:in `start'/usr/local/lib/ruby/1.8/webrick/server.rb:23:in `start'/usr/local/lib/ruby/1.8/webrick/server.rb:82:in `start'/usr/local/lib/ruby/1.8/xmlrpc/server.rb:648:in `serve'SupportServer.rb:216
--------------------------------------
|