0

我正在开发一个使用 MySQL 空间扩展的 Rails (2.3.4) 应用程序,因此我使用的是 GeoRuby (1.3.4) 和 spatial_adapter (1.1.2) gems。

然而,自从我开始使用 GeoRuby 的 Point 对象以来,当 ActiveSupport 在处理请求后尝试删除常量时,我​​遇到了麻烦:

[ pid=18105 thr=67398490 file=utils.rb:176 time=2010-12-07 15:00:38.894 ]: *** Exception NameError in application (cannot remove Object::Geometry) (process 18105, thread #<Thread:0x808d6b4>):
from /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:603:in `remove_const'
from /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:603:in `remove_constant'
from /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:603:in `instance_eval'
from /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:603:in `remove_constant'
from /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:450:in `remove_unloadable_constants!'
from /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:450:in `each'
from /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:450:in `remove_unloadable_constants!'
from /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:236:in `clear'
from /opt/local/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/dispatcher.rb:64:in `cleanup_application'
from /opt/local/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/reloader.rb:17:in `close'
from /opt/local/lib/ruby/gems/1.8/gems/passenger-3.0.0/lib/phusion_passenger/rack/request_handler.rb:136:in `process_request'
from /opt/local/lib/ruby/gems/1.8/gems/passenger-3.0.0/lib/phusion_passenger/abstract_request_handler.rb:513:in `accept_and_process_next_request'
from /opt/local/lib/ruby/gems/1.8/gems/passenger-3.0.0/lib/phusion_passenger/abstract_request_handler.rb:274:in `main_loop'
from /opt/local/lib/ruby/gems/1.8/gems/passenger-3.0.0/lib/phusion_passenger/classic_rails/application_spawner.rb:321:in `start_request_handler'
from /opt/local/lib/ruby/gems/1.8/gems/passenger-3.0.0/lib/phusion_passenger/classic_rails/application_spawner.rb:275:in `send'
from /opt/local/lib/ruby/gems/1.8/gems/passenger-3.0.0/lib/phusion_passenger/classic_rails/application_spawner.rb:275:in `handle_spawn_application'
from /opt/local/lib/ruby/gems/1.8/gems/passenger-3.0.0/lib/phusion_passenger/utils.rb:479:in `safe_fork'
from /opt/local/lib/ruby/gems/1.8/gems/passenger-3.0.0/lib/phusion_passenger/classic_rails/application_spawner.rb:270:in `handle_spawn_application'
from /opt/local/lib/ruby/gems/1.8/gems/passenger-3.0.0/lib/phusion_passenger/abstract_server.rb:357:in `__send__'
from /opt/local/lib/ruby/gems/1.8/gems/passenger-3.0.0/lib/phusion_passenger/abstract_server.rb:357:in `server_main_loop'
from /opt/local/lib/ruby/gems/1.8/gems/passenger-3.0.0/lib/phusion_passenger/abstract_server.rb:206:in `start_synchronously'
from /opt/local/lib/ruby/gems/1.8/gems/passenger-3.0.0/lib/phusion_passenger/abstract_server.rb:180:in `start'
from /opt/local/lib/ruby/gems/1.8/gems/passenger-3.0.0/lib/phusion_passenger/classic_rails/application_spawner.rb:149:in `start'
from /opt/local/lib/ruby/gems/1.8/gems/passenger-3.0.0/lib/phusion_passenger/spawn_manager.rb:219:in `spawn_rails_application'
from /opt/local/lib/ruby/gems/1.8/gems/passenger-3.0.0/lib/phusion_passenger/abstract_server_collection.rb:132:in `lookup_or_add'
from /opt/local/lib/ruby/gems/1.8/gems/passenger-3.0.0/lib/phusion_passenger/spawn_manager.rb:214:in `spawn_rails_application'
from /opt/local/lib/ruby/gems/1.8/gems/passenger-3.0.0/lib/phusion_passenger/abstract_server_collection.rb:82:in `synchronize'
from /opt/local/lib/ruby/gems/1.8/gems/passenger-3.0.0/lib/phusion_passenger/abstract_server_collection.rb:79:in `synchronize'
from /opt/local/lib/ruby/gems/1.8/gems/passenger-3.0.0/lib/phusion_passenger/spawn_manager.rb:213:in `spawn_rails_application'
from /opt/local/lib/ruby/gems/1.8/gems/passenger-3.0.0/lib/phusion_passenger/spawn_manager.rb:132:in `spawn_application'
from /opt/local/lib/ruby/gems/1.8/gems/passenger-3.0.0/lib/phusion_passenger/spawn_manager.rb:275:in `handle_spawn_application'
from /opt/local/lib/ruby/gems/1.8/gems/passenger-3.0.0/lib/phusion_passenger/abstract_server.rb:357:in `__send__'
from /opt/local/lib/ruby/gems/1.8/gems/passenger-3.0.0/lib/phusion_passenger/abstract_server.rb:357:in `server_main_loop'
from /opt/local/lib/ruby/gems/1.8/gems/passenger-3.0.0/lib/phusion_passenger/abstract_server.rb:206:in `start_synchronously'
from /opt/local/lib/ruby/gems/1.8/gems/passenger-3.0.0/helper-scripts/passenger-spawn-server:99

最终这会导致 Apache 收到一个 SIGTERM (可能是因为它耗尽了线程或其他东西),因此服务器有时无法响应任何请求。

奇怪的是“Object::Geometry”——我希望它改为“GeoRuby::SimpleFeatures::Geometry”(我使用了几个 GeoRuby::SimpleFeatures::Point's,它是 Geometry 的子类)。

我还注意到,在 ActiveSupport 3.0.0 中,remove_constant 的代码与我正在使用的版本不同。该更新是否解决了这个问题,如果可以,是否需要更新 Rails 3.0?

4

1 回答 1

0

我通过在 active_support/dependencies.rb 中使用 begin-rescue-end 子句包围有问题的代码(remove_constant 方法主体)来修复它,以忽略异常。我不确定这是否有任何负面影响,但至少它不会导致 Apache 时不时地重新启动。

于 2010-12-10T13:08:02.367 回答