几年前,我创建了基于mongodb 3.4和"locomotive_cms"gem的网站。 我的托管服务提供商将mongodb升级到3.6,我的网站在上传图像文件时收到此错误
Moped::Errors::OperationFailure (The operation: #<Moped::Protocol::Command
@length=468
...
failed with error 9: "The 'cursor' option is required, except for aggregate with the explain argument"
我使用mongoid (3.1.7(
它与轻便摩托车(聚合问题(有关
moped (1.5.3) lib/moped/node.rb:99:in `block in command'
moped (1.5.3) lib/moped/node.rb:600:in `block (3 levels) in flush'
moped (1.5.3) lib/moped/node.rb:599:in `map'
moped (1.5.3) lib/moped/node.rb:599:in `block (2 levels) in flush'
moped (1.5.3) lib/moped/node.rb:150:in `ensure_connected'
moped (1.5.3) lib/moped/node.rb:595:in `block in flush'
moped (1.5.3) lib/moped/node.rb:610:in `logging'
moped (1.5.3) lib/moped/node.rb:594:in `flush'
moped (1.5.3) lib/moped/node.rb:583:in `process'
moped (1.5.3) lib/moped/node.rb:92:in `command'
moped (1.5.3) lib/moped/session/context.rb:51:in `block in command'
moped (1.5.3) lib/moped/session/context.rb:105:in `block in with_node'
moped (1.5.3) lib/moped/cluster.rb:251:in `with_secondary'
moped (1.5.3) lib/moped/session/context.rb:104:in `with_node'
moped (1.5.3) lib/moped/session/context.rb:50:in `command'
moped (1.5.3) lib/moped/database.rb:76:in `command'
moped (1.5.3) lib/moped/session.rb:78:in `command'
moped (1.5.3) lib/moped/collection.rb:128:in `aggregate'
mongoid (3.1.7) lib/mongoid/contextual/aggregable/mongo.rb:27:in `aggregates'
mongoid (3.1.7) lib/mongoid/contextual/aggregable/mongo.rb:71:in `max'
mongoid (3.1.7) lib/mongoid/contextual.rb:11:in `max'
mongoid (3.1.7) lib/mongoid/finders.rb:13:in `max'
/usrcustom_fields (2.3.4) lib/custom_fields/types/belongs_to.rb:52:in `block in apply_belongs_to_custom_field'
activesupport (3.2.22.5) lib/active_support/callbacks.rb:440:in `_run__4082834224722639677__create__278889843058572249__callbacks'
activesupport (3.2.22.5) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.22.5) lib/active_support/callbacks.rb:385:in `_run_create_callbacks'
activesupport (3.2.22.5) lib/active_support/callbacks.rb:81:in `run_callbacks'
mongoid (3.1.7) lib/mongoid/callbacks.rb:130:in `run_callbacks'
mongoid (3.1.7) lib/mongoid/persistence/insertion.rb:24:in `block in prepare'
activesupport (3.2.22.5) lib/active_support/callbacks.rb:458:in `_run__4082834224722639677__save__278889843058572249__callbacks'
activesupport (3.2.22.5) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.22.5) lib/active_support/callbacks.rb:385:in `_run_save_callbacks'
activesupport (3.2.22.5) lib/active_support/callbacks.rb:81:in `run_callbacks'
mongoid (3.1.7) lib/mongoid/callbacks.rb:130:in `run_callbacks'
mongoid (3.1.7) lib/mongoid/persistence/insertion.rb:23:in `prepare'
mongoid (3.1.7) lib/mongoid/persistence/operations/insert.rb:26:in `persist'
mongoid (3.1.7) lib/mongoid/persistence.rb:56:in `insert'
mongoid (3.1.7) lib/mongoid/persistence.rb:85:in `save'
mongoid (3.1.7) lib/mongoid/relations/many.rb:44:in `create'
/usrlocomotive_cms (2.5.7) app/controllers/locomotive/content_entries_controller.rb:46:in `create'
actionpack (3.2.22.5) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
actionpack (3.2.22.5) lib/abstract_controller/base.rb:167:in `process_action'
actionpack (3.2.22.5) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (3.2.22.5) lib/abstract_controller/callbacks.rb:18:in `block in process_action'
activesupport (3.2.22.5) lib/active_support/callbacks.rb:569:in `block in _run__3965168837898506995__process_action__980960899211290186__callbacks'
activesupport (3.2.22.5) lib/active_support/callbacks.rb:215:in `block in _conditional_callback_around_842'
activesupport (3.2.22.5) lib/active_support/core_ext/time/zones.rb:45:in `use_zone'
locomotive_cms (2.5.7) lib/locomotive/action_controller/timezone.rb:8:in `set_timezone'
activesupport (3.2.22.5) lib/active_support/callbacks.rb:214:in `_conditional_callback_around_842'
activesupport (3.2.22.5) lib/active_support/callbacks.rb:502:in `_run__3965168837898506995__process_action__980960899211290186__callbacks'
activesupport (3.2.22.5) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.22.5) lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks'
activesupport (3.2.22.5) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.2.22.5) lib/abstract_controller/callbacks.rb:17:in `process_action'
actionpack (3.2.22.5) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (3.2.22.5) lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
activesupport (3.2.22.5) lib/active_support/notifications.rb:123:in `block in instrument'
activesupport (3.2.22.5) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (3.2.22.5) lib/active_support/notifications.rb:123:in `instrument'
actionpack (3.2.22.5) lib/action_controller/metal/instrumentation.rb:29:in `process_action'
actionpack (3.2.22.5) lib/action_controller/metal/params_wrapper.rb:207:in `process_action'
actionpack (3.2.22.5) lib/abstract_controller/base.rb:121:in `process'
actionpack (3.2.22.5) lib/abstract_controller/rendering.rb:46:in `process'
actionpack (3.2.22.5) lib/action_controller/metal.rb:203:in `dispatch'
actionpack (3.2.22.5) lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
actionpack (3.2.22.5) lib/action_controller/metal.rb:246:in `block in action'
actionpack (3.2.22.5) lib/action_dispatch/routing/route_set.rb:73:in `dispatch'
actionpack (3.2.22.5) lib/action_dispatch/routing/route_set.rb:36:in `call'
journey (1.0.4) lib/journey/router.rb:68:in `block in call'
journey (1.0.4) lib/journey/router.rb:56:in `each'
journey (1.0.4) lib/journey/router.rb:56:in `call'
actionpack (3.2.22.5) lib/action_dispatch/routing/route_set.rb:608:in `call'
railties (3.2.22.5) lib/rails/engine.rb:484:in `call'
railties (3.2.22.5) lib/rails/railtie/configurable.rb:30:in `method_missing'
journey (1.0.4) lib/journey/router.rb:68:in `block in call'
journey (1.0.4) lib/journey/router.rb:56:in `each'
journey (1.0.4) lib/journey/router.rb:56:in `call'
actionpack (3.2.22.5) lib/action_dispatch/routing/route_set.rb:608:in `call'
locomotive_cms (2.5.7) lib/locomotive/middlewares/locale_redirection.rb:13:in `call'
locomotive_cms (2.5.7) lib/locomotive/middlewares/locale.rb:11:in `call'
locomotive_cms (2.5.7) lib/locomotive/middlewares/site.rb:11:in `call'
locomotive_cms (2.5.7) lib/locomotive/middlewares/inline_editor.rb:10:in `call'
locomotive_cms (2.5.7) lib/locomotive/middlewares/seo_trailing_slash.rb:18:in `call'
dragonfly (1.0.12) lib/dragonfly/middleware.rb:14:in `call'
mongoid (3.1.7) lib/rack/mongoid/middleware/identity_map.rb:34:in `block in call'
mongoid (3.1.7) lib/mongoid/unit_of_work.rb:39:in `unit_of_work'
mongoid (3.1.7) lib/rack/mongoid/middleware/identity_map.rb:34:in `call'
warden (1.2.7) lib/warden/manager.rb:36:in `block in call'
warden (1.2.7) lib/warden/manager.rb:35:in `catch'
warden (1.2.7) lib/warden/manager.rb:35:in `call'
actionpack (3.2.22.5) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
rack (1.4.7) lib/rack/etag.rb:23:in `call'
rack (1.4.7) lib/rack/conditionalget.rb:35:in `call'
actionpack (3.2.22.5) lib/action_dispatch/middleware/head.rb:14:in `call'
actionpack (3.2.22.5) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
actionpack (3.2.22.5) lib/action_dispatch/middleware/flash.rb:242:in `call'
rack (1.4.7) lib/rack/session/abstract/id.rb:210:in `context'
rack (1.4.7) lib/rack/session/abstract/id.rb:205:in `call'
actionpack (3.2.22.5) lib/action_dispatch/middleware/cookies.rb:341:in `call'
actionpack (3.2.22.5) lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
activesupport (3.2.22.5) lib/active_support/callbacks.rb:405:in `_run__2523231567589513662__call__278889843058572249__callbacks'
activesupport (3.2.22.5) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.22.5) lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
activesupport (3.2.22.5) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.2.22.5) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (3.2.22.5) lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
actionpack (3.2.22.5) lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
actionpack (3.2.22.5) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
railties (3.2.22.5) lib/rails/rack/logger.rb:32:in `call_app'
railties (3.2.22.5) lib/rails/rack/logger.rb:16:in `block in call'
activesupport (3.2.22.5) lib/active_support/tagged_logging.rb:22:in `tagged'
railties (3.2.22.5) lib/rails/rack/logger.rb:16:in `call'
actionpack (3.2.22.5) lib/action_dispatch/middleware/request_id.rb:22:in `call'
rack (1.4.7) lib/rack/methodoverride.rb:21:in `call'
rack (1.4.7) lib/rack/runtime.rb:17:in `call'
dragonfly (1.0.12) lib/dragonfly/cookie_monster.rb:9:in `call'
activesupport (3.2.22.5) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
rack (1.4.7) lib/rack/lock.rb:15:in `call'
rack-cache (1.8.0) lib/rack/cache/context.rb:140:in `forward'
rack-cache (1.8.0) lib/rack/cache/context.rb:147:in `pass'
rack-cache (1.8.0) lib/rack/cache/context.rb:159:in `invalidate'
rack-cache (1.8.0) lib/rack/cache/context.rb:74:in `call!'
rack-cache (1.8.0) lib/rack/cache/context.rb:51:in `call'
locomotive_cms (2.5.7) lib/locomotive/middlewares/permalink.rb:17:in `call'
railties (3.2.22.5) lib/rails/engine.rb:484:in `call'
railties (3.2.22.5) lib/rails/application.rb:231:in `call'
railties (3.2.22.5) lib/rails/railtie/configurable.rb:30:in `method_missing'
/usr/local/lib/ruby/gems/2.3/gems/passenger-5.1.12/src/ruby_supportlib/phusion_passenger/rack/thread_handler_extension.rb:97:in `process_request'
/usr/local/lib/ruby/gems/2.3/gems/passenger-5.1.12/src/ruby_supportlib/phusion_passenger/request_handler/thread_handler.rb:160:in `accept_and_process_next_request'
/usr/local/lib/ruby/gems/2.3/gems/passenger-5.1.12/src/ruby_supportlib/phusion_passenger/request_handler/thread_handler.rb:113:in `main_loop'
/usr/local/lib/ruby/gems/2.3/gems/passenger-5.1.12/src/ruby_supportlib/phusion_passenger/request_handler.rb:416:in `block (3 levels) in start_threads'
/usr/local/lib/ruby/gems/2.3/gems/passenger-5.1.12/src/ruby_supportlib/phusion_passenger/utils.rb:113:in `block in create_thread_and_abort_on_exception'
我尝试更新版本,但我只得到了这个版本,它不适用于 mongodb 3.6...
locomotive_cms (>= 2.5.7, ~> 2.5) was resolved to 2.5.7, which depends on
moped (~> 1.5.3)
这真的很烦人,因为我无法降级数据库,也无法更新cms。我发现一段时间以来有新的机车 cms,但在先决条件中仍然有 mongodb 3.4,我想它的工作原理并不完全相同,名称更改为"机车 cms"宝石。
好的,我在这里找到了解决方案 https://github.com/mongoid/moped/issues/283(mhuggins回答( 并稍微改变了它
def aggregate(*pipeline)
# Ordering of keys apparently matters to Mongo -- `aggregate` has to come before `cursor` here.
extract_result(database.session.command(aggregate: name, pipeline: pipeline.flatten, cursor: {}))
end
包含database.session
而不是session
默认情况下,这会将光标添加到聚合函数。毕竟,覆盖这个函数并不难,但找到它导致的原因更难。
无论如何,我把这个问题留在这里,也许有人觉得它有用。