Created
January 19, 2013 10:06
-
-
Save paulwalker/4571746 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'mongo' | |
include Mongo | |
@client = MongoClient.new('localhost', 27017) | |
@db = @client['tail-db-failure'] | |
@coll = @db.create_collection('foo', :capped => true, :size => 1024, :max => 1) | |
@coll.insert({ :foo => 'bar'} ) | |
@cursor = Mongo::Cursor.new(@coll, :tailable => true, :timeout => false, :order => [['$natural', 1]]) | |
@cursor.add_option(Mongo::Constants::OP_QUERY_AWAIT_DATA) | |
puts @cursor.next_document.inspect | |
# => #<BSON::OrderedHash:0x7d2 {"_id"=>BSON::ObjectId('50fa6eb6744e4bf7959ac60f'), "foo"=>"bar"}> | |
puts @cursor.next_document.inspect | |
# => nil | |
@coll.insert({ :foo => 'bar2' }) | |
puts @cursor.next_document.inspect | |
# Mongo::OperationFailure: Query response returned CURSOR_NOT_FOUND. Either an invalid cursor was specified, or the cursor may have timed out on the server. | |
# check_response_flags at /Users/paul/.rvm/gems/jruby-1.6.8@yeti/gems/mongo-1.8.2/lib/mongo/networking.rb:191 | |
# receive_response_header at /Users/paul/.rvm/gems/jruby-1.6.8@yeti/gems/mongo-1.8.2/lib/mongo/networking.rb:184 | |
# receive at /Users/paul/.rvm/gems/jruby-1.6.8@yeti/gems/mongo-1.8.2/lib/mongo/networking.rb:151 | |
# receive_message at /Users/paul/.rvm/gems/jruby-1.6.8@yeti/gems/mongo-1.8.2/lib/mongo/networking.rb:117 | |
# send_get_more at /Users/paul/.rvm/gems/jruby-1.6.8@yeti/gems/mongo-1.8.2/lib/mongo/cursor.rb:529 | |
# refresh at /Users/paul/.rvm/gems/jruby-1.6.8@yeti/gems/mongo-1.8.2/lib/mongo/cursor.rb:463 | |
# next at /Users/paul/.rvm/gems/jruby-1.6.8@yeti/gems/mongo-1.8.2/lib/mongo/cursor.rb:124 | |
# (root) at /Users/paul/mellmo-git/web-server/tailable_cursor_bug_reduction.rb:24 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment