环境
我有两个网络服务器:web1和web2之间的rails 3.2.x app负载平衡。每个Web服务器都指向mysql数据库的集群IP。该数据库是2台服务器集群(通过rackspace)。 1个数据库一直处于活动状态,直到故障转移。
错误
在我们最新的故障转移上,web1开始在ActiveRecord::ConnectionTimeoutError
上发送Middleware/Rack/ActiveRecord::QueryCache#call
(下面的堆栈跟踪),而web2没有错误。请注意,这是在DB稳定并且100%切换到另一个节点之后发生的。
理论
我的理论是会话或缓存或连接引用旧节点,一旦切换它就找不到所说的连接。这看起来很奇怪,因为两个数据库节点都是集群的,在同一个集群IP上提供服务并进行复制。
临时解决方案
我们的临时解决方案是重启web1 rails服务器,这很有用。
问题
1)我想知道我是否可以解释这里可能发生的事情
2)是否存在可能在将来阻止此操作的配置设置。
堆栈跟踪
错误讯息 ActiveRecord :: ConnectionTimeoutError:无法在5秒内获得数据库连接(等待5.000268907秒)。最大池大小目前为5;考虑增加它。
... record / connection_adapters / abstract / connection_pool.rb:258:in block (2 levels) in checkout'
…record/connection_adapters/abstract/connection_pool.rb: 242:in
循环'
... record / connection_adapters / abstract / connection_pool.rb:242:in block in checkout'
/usr/local/lib/ruby/1.9.1/monitor.rb: 211:in
mon_synchronize'
... record / connection_adapters / abstract / connection_pool.rb:239:在checkout'
…record/connection_adapters/abstract/connection_pool.rb: 102:in
块中连接'
/usr/local/lib/ruby/1.9.1/monitor.rb:211:mon_synchronize'
…record/connection_adapters/abstract/connection_pool.rb: 101:in
连接'
... record / connection_adapters / abstract / connection_pool.rb:410:在retrieve_connection'
…nnection_adapters/abstract/connection_specification.rb: 171:in
retrieve_connection'
... nnection_adapters / abstract / connection_specification.rb:145:connection'
…s/activerecord-3.2.19/lib/active_record/query_cache.rb: 67:in
救援电话'
... s / activerecord-3.2.19 / lib / active_record / query_cache.rb:61:in call'
…record/connection_adapters/abstract/connection_pool.rb: 479:in
call'
... ack-3.2.19 / lib / action_dispatch / middleware / callbacks.rb:28:in block in call'
…s/activesupport-3.2.19/lib/active_support/callbacks.rb: 405:in
_ run__862588711471957735__call__1324336831638990183__callbacks'
... s / activesupport-3.2.19 / lib / active_support / callbacks.rb:405:在__run_callback'
…s/activesupport-3.2.19/lib/active_support/callbacks.rb: 385:in
_ run_call_callbacks'
... s / activesupport-3.2.19 / lib / active_support / callbacks.rb:81:in run_callbacks'
…ack-3.2.19/lib/action_dispatch/middleware/callbacks.rb: 27:in
来电'
... ack-3.2.19 / lib / action_dispatch / middleware / remote_ip.rb:31:in call'
…/gems/airbrake-3.1.14/lib/airbrake/rails/middleware.rb: 13:in
来电'
... .19 / lib / action_dispatch / middleware / debug_exceptions.rb:16:in call'
…2.19/lib/action_dispatch/middleware/show_exceptions.rb: 56:in
来电'
... / / 1.9.1 / gems / railties-3.2.19 / lib / rails / rack / logger.rb:32:in call_app'
…by/1.9.1/gems/railties-3.2.19/lib/rails/rack/logger.rb: 16:in
阻止通话'
... ivesupport-3.2.19 / lib / active_support / tagged_logging.rb:22:in tagged'
…by/1.9.1/gems/railties-3.2.19/lib/rails/rack/logger.rb: 16:in
来电'
... ck-3.2.19 / lib / action_dispatch / middleware / request_id.rb:22:in call'
…/ruby/1.9.1/gems/rack-1.4.5/lib/rack/methodoverride.rb: 21:in
来电'
... / bundle / ruby / 1.9.1 / gems / rack-1.4.5 / lib / rack / runtime.rb:17:in call'
…9.1/gems/airbrake-3.1.14/lib/airbrake/user_informer.rb: 16:in
_ call'
... 9.1 / gems / airbrake-3.1.14 / lib / airbrake / user_informer.rb:12:in call'
…le/ruby/1.9.1/gems/railties-3.2.19/lib/rails/engine.rb: 484:in
来电'
...由/ 1.9.1 / gems / railties-3.2.19 / lib / rails / application.rb:231:在call'
…gems/railties-3.2.19/lib/rails/railtie/configurable.rb: 30:in
method_missing'
... r-3.0.13 / lib / phusion_passenger / rack / request_handler.rb:96:在`process_request'