Uploaded image for project: 'Drivers'
  1. Drivers
  2. DRIVERS-421

Cursor iteration should complete (abnormally) when another thread closes the cursor

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Fixed
    • Icon: Major - P3 Major - P3
    • None
    • None
    • Needed
    • $i18n.getText("admin.common.words.hide")
      Key Status/Resolution FixVersion
      JAVA-2651 Fixed 3.6.0
      NODE-1185 Works as Designed
      SCALA-351 Works as Designed
      PYTHON-1408 Fixed 3.6
      CSHARP-2092 Fixed 2.10.0
      PERL-815 Won't Fix
      RUBY-1253 Fixed 2.18.2
      CXX-1469 Works as Designed
      PHPC-1034 Works as Designed
      GODRIVER-125 Won't Fix
      CDRIVER-2361 Works as Designed 1.9.0
      RUST-168 Fixed 0.9.0-alpha
      SWIFT-483 Won't Do
      $i18n.getText("admin.common.words.show")
      #scriptField, #scriptField *{ border: 1px solid black; } #scriptField{ border-collapse: collapse; } #scriptField td { text-align: center; /* Center-align text in table cells */ } #scriptField td.key { text-align: left; /* Left-align text in the Key column */ } #scriptField a { text-decoration: none; /* Remove underlines from links */ border: none; /* Remove border from links */ } /* Add green background color to cells with FixVersion */ #scriptField td.hasFixVersion { background-color: #00FF00; /* Green color code */ } /* Center-align the first row headers */ #scriptField th { text-align: center; } Key Status/Resolution FixVersion JAVA-2651 Fixed 3.6.0 NODE-1185 Works as Designed SCALA-351 Works as Designed PYTHON-1408 Fixed 3.6 CSHARP-2092 Fixed 2.10.0 PERL-815 Won't Fix RUBY-1253 Fixed 2.18.2 CXX-1469 Works as Designed PHPC-1034 Works as Designed GODRIVER-125 Won't Fix CDRIVER-2361 Works as Designed 1.9.0 RUST-168 Fixed 0.9.0-alpha SWIFT-483 Won't Do

    Description

      In order to make cursor iteration blocking for tailable cursors, and in general to support the possibility of empty batches, driver implementations of cursor iteration typically have an inner loop within the method that advances the cursor:

              while (serverCursor != null) {
                  _nextBatch = getMore();
                  if (!_nextBatch.isEmpty()) {
                      return true;  // has more results
                  }
              }
              return false;  // no more results
      

      Drivers should ensure that there is a check within that loop that the cursor has not been closed by another thread in the application.

              while (serverCursor != null) {
                 _nextBatch = getMore();
                  
                 // if another thread closed the cursor, throw an exception so that this method terminates
                 if (_closed) {
                     throw ...  
                 }
       
                 if (!_nextBatch.isEmpty()) {
                     return true;  // has more results
                 }
              }
              return false;  // no more results
      

      This is necessary because a call to killCursors from the close method of the cursor will fail if there is a getMore in progress on that cursor, and thus the repeated calls to getMore in the loop will never encounter a cursorNotFound error and the loop will not exit.

      Attachments

        Activity

          People

            Unassigned Unassigned
            jeff.yemin@mongodb.com Jeffrey Yemin
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: