ClientSession cannot be reborrowed while iterating a cursor

XMLWordPrintableJSON

    • Type: New Feature
    • Resolution: Fixed
    • Priority: Critical - P2
    • 2.0.0-beta
    • Affects Version/s: 2.0.0-alpha.1
    • Component/s: None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Currently, the session used by a SessionCursorHandle cannot be reborrowed within the while let loop that iterates over the cursor. This makes using cursors with sessions pretty clunky.

      repro:

       let mut cursor = coll.find_with_session(doc! {}, None, &mut session).await?
      // cursor does not retain the reference, so it can be used here
      coll.run_command_with_session(doc! { "ping": 1 }, None, &mut session).await?;
      
      while let Some(doc) = cursor.with_session(&mut_session).next().await? {
          println!("{}", doc?);
          // following line errors saying the session is already borrowed
          coll.run_command_with_session(doc! { "ping": 1 }, None, &mut session).await?;
      }

              Assignee:
              Patrick Freed
              Reporter:
              Patrick Freed
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: