Calling cursor.begin() multiple times while it is pending will cause an exception

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Works as Designed
    • Priority: Major - P3
    • None
    • Affects Version/s: 3.2.0
    • Component/s: None
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      If a tailable cursor is opened against a collection, and it does not return any results on initial 3 calls to cursor.begin() it will fail with Cannot advance a completed or failed cursor.: generic server error.

      This is due to this line of code which will advance the cursor without checking to see if there are any results available.

      Suggest that the code be changed to something like:

          if (libmongoc::cursor_more(_cursor->_impl->cursor_t) &&
                  libmongoc::cursor_next(_cursor->_impl->cursor_t, &out)) {
              _cursor->_impl->doc = bsoncxx::document::view{bson_get_data(out), out->len};
          } else if ...
      

            Assignee:
            Unassigned
            Reporter:
            John Murphy
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: