找不到Mongo Ruby Driver Cursor错误

时间:2016-08-02 20:41:35

标签: ruby mongodb

我使用ruby驱动程序从mongodb找到文档,将它们收集到数组并迭代它们以更新与下面代码中相同的文档:

crawlarray = @@mongoclient[:crawlarray].find({searchresults:[]},:timeout => false).limit(500)
crawlarray.each do |elm|
    finalsearchstring = elm['searchstring'] 
    if elm["searchresults"].blank?
        ap "SEARCHING: #{finalsearchstring}"
        results = searchG(finalsearchstring) 
        elm["searchresults"] = results
        @@mongoclient[:crawlarray].update_one({"_id" => elm['_id']}, elm)
    else
        ap "ALREADY SEARCHED: #{finalsearchstring}"
    end
end

有90K的记录,但正如你所看到的,我只得到500就不会得到错误。每次,经过大约150次迭代后我得到这个错误;

D, [2016-08-02T22:32:08.853065 #10098] DEBUG -- : MONGODB | 127.0.0.1:27017 | posluga-dev.getMore | FAILED | Cursor not found, cursor id: 463388278686 (43) | 0.008009s
/Users/apple/.rvm/gems/ruby-2.2.1/gems/mongo-2.2.7/lib/mongo/operation/result.rb:256:in `validate!': Cursor not found, cursor id: 463388278686 (43) (Mongo::Error::OperationFailure)
    from /Users/apple/.rvm/gems/ruby-2.2.1/gems/mongo-2.2.7/lib/mongo/operation/executable.rb:36:in `block in execute'
    from /Users/apple/.rvm/gems/ruby-2.2.1/gems/mongo-2.2.7/lib/mongo/server/connection_pool.rb:107:in `with_connection'
    from /Users/apple/.rvm/gems/ruby-2.2.1/gems/mongo-2.2.7/lib/mongo/server/context.rb:63:in `with_connection'
    from /Users/apple/.rvm/gems/ruby-2.2.1/gems/mongo-2.2.7/lib/mongo/operation/executable.rb:34:in `execute'
    from /Users/apple/.rvm/gems/ruby-2.2.1/gems/mongo-2.2.7/lib/mongo/cursor.rb:163:in `block in get_more'
    from /Users/apple/.rvm/gems/ruby-2.2.1/gems/mongo-2.2.7/lib/mongo/retryable.rb:51:in `call'
    from /Users/apple/.rvm/gems/ruby-2.2.1/gems/mongo-2.2.7/lib/mongo/retryable.rb:51:in `read_with_retry'
    from /Users/apple/.rvm/gems/ruby-2.2.1/gems/mongo-2.2.7/lib/mongo/cursor.rb:162:in `get_more'
    from /Users/apple/.rvm/gems/ruby-2.2.1/gems/mongo-2.2.7/lib/mongo/cursor.rb:88:in `each'
    from /Users/apple/.rvm/gems/ruby-2.2.1/gems/mongo-2.2.7/lib/mongo/collection/view/iterable.rb:44:in `each'

有人可以帮我解决一下吗?

0 个答案:

没有答案