相关疑难解决方法(0)

mongo db中的tailable游标超时

我正在尝试在ruby中创建一个oplog观察器.到目前为止,我已经在下面提出了一个小脚本.

require 'rubygems'
require 'mongo'
db = Mongo::Connection.new("localhost", 5151).db("local")
coll = db.collection('oplog.$main')

loop do
cursor = Mongo::Cursor.new(coll, :tailable => true)
    while not cursor.closed?
        if doc = cursor.next_document
            puts doc
        else
            sleep 1
        end
    end
end
Run Code Online (Sandbox Code Playgroud)

这个问题是,经过5或6秒后,当它吐出大量数据时,它会超时并且我得到一个错误

C:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/mongo-1.4.0/lib/../lib/mongo/connection.rb
:807:in `check_response_flags': Query response returned CURSOR_NOT_FOUND. Either an invalid c
ursor was specified, or the cursor may have timed out on the server. (Mongo::OperationFailure
)
        from C:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/mongo-1.4.0/lib/../lib/mongo/
connection.rb:800:in `receive_response_header'
        from C:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/mongo-1.4.0/lib/../lib/mongo/
connection.rb:768:in `receive'
        from C:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/mongo-1.4.0/lib/../lib/mongo/
connection.rb:493:in `receive_message'
        from C:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/mongo-1.4.0/lib/../lib/mongo/
connection.rb:491:in `synchronize'
        from C:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/mongo-1.4.0/lib/../lib/mongo/ …
Run Code Online (Sandbox Code Playgroud)

ruby mongodb

6
推荐指数
1
解决办法
1568
查看次数

标签 统计

mongodb ×1

ruby ×1