gpt4 book ai didi

mongodb - Mongo::OperationFailure,数据库命令 'filemd5' 失败:(errmsg:'异常:已请求最佳猜测计划,但需要扫描和排序)

转载 作者:可可西里 更新时间:2023-11-01 10:44:47 25 4
gpt4 key购买 nike

我有一个应用程序可以通过 Padrino 中的 MongoMapper/Joint 将文件上传到 GridFS。一切正常,然后突然出现错误:

Mongo::OperationFailure at /admin/wallpapers/create
Database command 'filemd5' failed: (errmsg: 'exception: best guess plan requested, but scan and order required: query: { files_id: ObjectId('4eaf4abf9972772c94000003') } order: { files_id: 1, n: 1 } choices: { $natural: 1 } '; code: '13284'; ok: '0.0').

堆栈跟踪:

Mongo::OperationFailure - Database command 'filemd5' failed: (errmsg: 'exception: best guess plan requested, but scan and order required: query: { files_id: ObjectId('4eaf4c719972772c9400000b') } order: { files_id: 1, n: 1 } choices: { $natural: 1 } '; code: '13284'; ok: '0.0').:
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/mongo-1.4.1/lib/mongo/db.rb:520:in `command'
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/mongo-1.4.1/lib/mongo/gridfs/grid_io.rb:463:in `get_md5'
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/mongo-1.4.1/lib/mongo/gridfs/grid_io.rb:453:in `to_mongo_object'
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/mongo-1.4.1/lib/mongo/gridfs/grid_io.rb:238:in `close'
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/mongo-1.4.1/lib/mongo/gridfs/grid.rb:73:in `put'
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/joint-0.6.0/lib/joint/instance_methods.rb:22:in `block in save_attachments'
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/joint-0.6.0/lib/joint/instance_methods.rb:18:in `each_pair'
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/joint-0.6.0/lib/joint/instance_methods.rb:18:in `save_attachments'
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/activesupport-3.0.10/lib/active_support/callbacks.rb:416:in `_run_save_callbacks'
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/activesupport-3.0.10/lib/active_support/callbacks.rb:94:in `run_callbacks'
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/mongo_mapper-0.9.2/lib/mongo_mapper/plugins/embedded_callbacks.rb:28:in `run_callbacks'
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/mongo_mapper-0.9.2/lib/mongo_mapper/plugins/callbacks.rb:14:in `create_or_update'
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/mongo_mapper-0.9.2/lib/mongo_mapper/plugins/querying.rb:143:in `save'
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/mongo_mapper-0.9.2/lib/mongo_mapper/plugins/dirty.rb:20:in `block in save'
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/mongo_mapper-0.9.2/lib/mongo_mapper/plugins/dirty.rb:42:in `clear_changes'
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/mongo_mapper-0.9.2/lib/mongo_mapper/plugins/dirty.rb:20:in `save'
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/mongo_mapper-0.9.2/lib/mongo_mapper/plugins/validations.rb:23:in `save'
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/mongo_mapper-0.9.2/lib/mongo_mapper/plugins/querying.rb:30:in `block in create'
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/mongo_mapper-0.9.2/lib/mongo_mapper/plugins/querying.rb:113:in `block in initialize_each'
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/mongo_mapper-0.9.2/lib/mongo_mapper/plugins/querying.rb:111:in `each'
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/mongo_mapper-0.9.2/lib/mongo_mapper/plugins/querying.rb:111:in `initialize_each'
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/mongo_mapper-0.9.2/lib/mongo_mapper/plugins/querying.rb:30:in `create'
/var/www/fhsclock/admin/controllers/wallpapers.rb:13:in `block (2 levels) in <top (required)>'
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/padrino-core-0.10.0/lib/padrino-core/application/routing.rb:486:in `call'
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/padrino-core-0.10.0/lib/padrino-core/application/routing.rb:486:in `block in route'
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/sinatra-1.2.7/lib/sinatra/base.rb:736:in `instance_eval'
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/sinatra-1.2.7/lib/sinatra/base.rb:736:in `route_eval'
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/padrino-core-0.10.0/lib/padrino-core/application/routing.rb:49:in `block (2 levels) in process_destination_path'
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/padrino-core-0.10.0/lib/padrino-core/application/routing.rb:49:in `catch'
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/padrino-core-0.10.0/lib/padrino-core/application/routing.rb:49:in `block in process_destination_path'
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/padrino-core-0.10.0/lib/padrino-core/application/routing.rb:22:in `instance_eval'
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/padrino-core-0.10.0/lib/padrino-core/application/routing.rb:22:in `process_destination_path'
(eval):16:in `block (2 levels) in inject_root_methods'
(eval):6:in `catch'
(eval):6:in `block in inject_root_methods'
(eval):313:in `block in inject_root_methods'
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/http_router-0.8.11/lib/http_router/node/root.rb:68:in `[]'
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/http_router-0.8.11/lib/http_router.rb:110:in `block in call'
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/http_router-0.8.11/lib/http_router.rb:110:in `catch'
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/http_router-0.8.11/lib/http_router.rb:110:in `call'
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/padrino-core-0.10.0/lib/padrino-core/application/routing.rb:796:in `route!'
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/padrino-core-0.10.0/lib/padrino-core/application/routing.rb:785:in `dispatch!'
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/sinatra-1.2.7/lib/sinatra/base.rb:656:in `block in call!'
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/sinatra-1.2.7/lib/sinatra/base.rb:820:in `block in invoke'
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/sinatra-1.2.7/lib/sinatra/base.rb:820:in `catch'
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/sinatra-1.2.7/lib/sinatra/base.rb:820:in `invoke'
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/sinatra-1.2.7/lib/sinatra/base.rb:656:in `call!'
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/sinatra-1.2.7/lib/sinatra/base.rb:641:in `call'
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/rack-flash-0.1.2/lib/rack/flash.rb:147:in `call'
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/padrino-core-0.10.0/lib/padrino-core/reloader.rb:243:in `call'
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/padrino-core-0.10.0/lib/padrino-core/logger.rb:300:in `call'
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/sinatra-1.2.7/lib/sinatra/showexceptions.rb:21:in `call'
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/rack-1.3.5/lib/rack/session/abstract/id.rb:195:in `context'
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/rack-1.3.5/lib/rack/session/abstract/id.rb:190:in `call'
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/rack-1.3.5/lib/rack/head.rb:9:in `call'
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/sinatra-1.2.7/lib/sinatra/showexceptions.rb:21:in `call'
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/rack-1.3.5/lib/rack/methodoverride.rb:24:in `call'
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/sinatra-1.2.7/lib/sinatra/base.rb:1292:in `block in call'
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/sinatra-1.2.7/lib/sinatra/base.rb:1323:in `synchronize'
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/sinatra-1.2.7/lib/sinatra/base.rb:1292:in `call'
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/padrino-core-0.10.0/lib/padrino-core/router.rb:71:in `block in call'
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/padrino-core-0.10.0/lib/padrino-core/router.rb:64:in `each'
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/padrino-core-0.10.0/lib/padrino-core/router.rb:64:in `call'
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/thin-1.2.11/lib/thin/connection.rb:84:in `block in pre_process'
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/thin-1.2.11/lib/thin/connection.rb:82:in `catch'
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/thin-1.2.11/lib/thin/connection.rb:82:in `pre_process'
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/thin-1.2.11/lib/thin/connection.rb:57:in `process'
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/thin-1.2.11/lib/thin/connection.rb:42:in `receive_data'
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/eventmachine-0.12.10/lib/eventmachine.rb:256:in `run_machine'
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/eventmachine-0.12.10/lib/eventmachine.rb:256:in `run'
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/thin-1.2.11/lib/thin/backends/base.rb:61:in `start'
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/thin-1.2.11/lib/thin/server.rb:159:in `start'
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/rack-1.3.5/lib/rack/handler/thin.rb:13:in `run'
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/rack-1.3.5/lib/rack/server.rb:265:in `start'
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/padrino-core-0.10.0/lib/padrino-core/server.rb:44:in `start'
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/padrino-core-0.10.0/lib/padrino-core/server.rb:34:in `start'
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/padrino-core-0.10.0/lib/padrino-core/server.rb:13:in `run!'
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/padrino-core-0.10.0/lib/padrino-core/cli/adapter.rb:7:in `start'
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/padrino-core-0.10.0/lib/padrino-core/cli/base.rb:24:in `start'
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/thor-0.14.6/lib/thor/task.rb:22:in `run'
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/thor-0.14.6/lib/thor/invocation.rb:118:in `invoke_task'
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/thor-0.14.6/lib/thor.rb:263:in `dispatch'
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/thor-0.14.6/lib/thor/base.rb:389:in `start'
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/padrino-core-0.10.0/bin/padrino:9:in `<top (required)>'
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/bin/padrino:19:in `load'
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/bin/padrino:19:in `<main>'

This thread MongoMapper 组建议我在 files.chunk 集合上运行 ensure_index(或 create_index)。但是,我不知道如何使用 MongoMapper 执行此操作。

有什么办法可以避免这种情况吗?

最佳答案

我遇到了同样的问题,正如作者所建议的那样,行:

db.fs.chunks.ensureIndex({files_id: 1, n: 1})

内部mongo控制台帮助。

完整的算法是:

  1. 打开终端,输入 mongo .按回车键。
  2. 输入 use <your database name> .按回车键。
  3. 输入 db.fs.chunks.ensureIndex({files_id: 1, n: 1}) .按回车键。

关于mongodb - Mongo::OperationFailure,数据库命令 'filemd5' 失败:(errmsg:'异常:已请求最佳猜测计划,但需要扫描和排序),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7961653/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com