Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-448

Tailable Cursor and awaitdata

    • Type: Icon: Task Task
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • 2.7
    • Affects Version/s: 2.6.5
    • Component/s: API
    • Environment:
      Linux 64 bit Ubuntu, Java 7 Jruby 1.6.4 with 2.6.5 of the java driver on Mongo 1.8.3
    • Major Change

      In tests, using a tailable cursor and a capped collection, I can fill the collection with say 10 docs and read them back. If I then ask for next doc, my test never ends. In the test setup if I set a thread to wait for 6 seconds before adding a doc to the collection the test does end. I did a thread dump while the test blocked. See further down

      Please confirm that the java driver should eventually return a nil doc assuming the await data option is set. Or confirm that this behaviour is for a future version.

      – Dump (some jruby lines removed) –

      "ScriptThreadProcess: ./test/collection_test.rb" daemon prio=10 tid=0x0000000002959000 nid=0x55b9 runnable [0x00007f2b2b7c1000]
      java.lang.Thread.State: RUNNABLE
      at java.net.SocketInputStream.socketRead0(Native Method)
      at java.net.SocketInputStream.read(SocketInputStream.java:150)
      at java.net.SocketInputStream.read(SocketInputStream.java:121)
      at java.io.BufferedInputStream.fill(BufferedInputStream.java:235)
      at java.io.BufferedInputStream.read1(BufferedInputStream.java:275)
      at java.io.BufferedInputStream.read(BufferedInputStream.java:334)

      • locked <0x00000000eab22188> (a java.io.BufferedInputStream)
        at org.bson.io.Bits.readFully(Bits.java:35)
        at org.bson.io.Bits.readFully(Bits.java:28)
        at com.mongodb.Response.<init>(Response.java:39)
        at com.mongodb.DBPort.go(DBPort.java:123)
      • locked <0x00000000eaaf8d88> (a com.mongodb.DBPort)
        at com.mongodb.DBPort.go(DBPort.java:82)
      • locked <0x00000000eaaf8d88> (a com.mongodb.DBPort)
        at com.mongodb.DBPort.call(DBPort.java:72)
        at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:202)
        at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:186)
        at com.mongodb.DBApiLayer$Result._advance(DBApiLayer.java:424)
        at com.mongodb.DBApiLayer$Result.next(DBApiLayer.java:396)
        at com.mongodb.DBApiLayer$Result.next(DBApiLayer.java:397)
        at com.mongodb.DBApiLayer$Result.next(DBApiLayer.java:397)
        at com.mongodb.DBApiLayer$Result.next(DBApiLayer.java:397)
        at com.mongodb.DBApiLayer$Result.next(DBApiLayer.java:397)
        at com.mongodb.DBApiLayer$Result.next(DBApiLayer.java:1)
        at com.mongodb.DBCursor._next(DBCursor.java:445)
        at com.mongodb.DBCursor.next(DBCursor.java:525)
        at com.mongodb.DBCursor.next(DBCursor.java:1)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:601)
        at org.jruby.javasupport.JavaMethod.invokeDirectWithExceptionHandling(JavaMethod.java:508)
        at org.jruby.javasupport.JavaMethod.invokeDirect(JavaMethod.java:368)
        at org.jruby.java.invokers.InstanceMethodInvoker.call(InstanceMethodInvoker.java:50)
        at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:133)
        at org.jruby.ast.CallNoArgNode.interpret(CallNoArgNode.java:63)
        at org.jruby.ast.FCallOneArgNode.interpret(FCallOneArgNode.java:36)
        at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:104)
        at org.jruby.evaluator.ASTInterpreter.INTERPRET_METHOD(ASTInterpreter.java:75)
        at org.jruby.internal.runtime.methods.InterpretedMethod.call(InterpretedMethod.java:147)
        at org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:163)
        at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:133)
        at org.jruby.ast.VCallNode.interpret(VCallNode.java:86)
        at org.jruby.ast.LocalAsgnNode.interpret(LocalAsgnNode.java:123)
        at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:104)
        at org.jruby.ast.IfNode.interpret(IfNode.java:117)
        at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:104)
        at org.jruby.evaluator.ASTInterpreter.INTERPRET_BLOCK(ASTInterpreter.java:112)
        at org.jruby.runtime.Interpreted19Block.evalBlockBody(Interpreted19Block.java:203)
        at org.jruby.runtime.Interpreted19Block.yield(Interpreted19Block.java:154)
        at org.jruby.runtime.Interpreted19Block.yieldSpecific(Interpreted19Block.java:127)
        at org.jruby.runtime.Block.yieldSpecific(Block.java:99)
        at org.jruby.ast.ZYieldNode.interpret(ZYieldNode.java:25)
        at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:104)
        at org.jruby.ast.RescueNode.executeBody(RescueNode.java:216)
        at org.jruby.ast.RescueNode.interpretWithJavaExceptions(RescueNode.java:120)
        at org.jruby.ast.RescueNode.interpret(RescueNode.java:110)
        at org.jruby.ast.BeginNode.interpret(BeginNode.java:83)
        at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:104)
        at org.jruby.evaluator.ASTInterpreter.INTERPRET_METHOD(ASTInterpreter.java:75)
        at org.jruby.internal.runtime.methods.InterpretedMethod.call(InterpretedMethod.java:212)
        at org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:187)
        at org.jruby.runtime.callsite.CachingCallSite.callBlock(CachingCallSite.java:176)
        at org.jruby.runtime.callsite.CachingCallSite.callIter(CachingCallSite.java:187)
        at org.jruby.ast.FCallOneArgBlockNode.interpret(FCallOneArgBlockNode.java:34)
        at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:104)
        at org.jruby.ast.BlockNode.interpret(BlockNode.java:71)
        at org.jruby.evaluator.ASTInterpreter.INTERPRET_METHOD(ASTInterpreter.java:75)
        at org.jruby.internal.runtime.methods.InterpretedMethod.call(InterpretedMethod.java:147)
        at org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:163)
        at org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:292)
        at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:135)
        at $dot.test.collection_test.block_5$RUBY$_file_(./test/collection_test.rb:941)

      JRUBY
      it "should find using a tailable cursor" do
      tail = Mongo::Cursor.new(@capped, :timeout => false, :tailable => true,
      :await_data => true, :order => [['$natural', 1]])

      10.times do
      assert tail.next_document
      end

      Thread.new(@capped) do |col|
      sleep 6
      1.times { col.insert({:n => 100}) }
      end

      assert true, tail.alive?

      1. blocks forever unless using thread to insert
        #assert_nil tail.next_document
      1. blocks until thread inserts docs
        assert tail.next_document

      assert tail.next_document
      end

            Assignee:
            Unassigned Unassigned
            Reporter:
            guyboertje Guy Boertje
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: