Uploaded image for project: 'Go Driver'
  1. Go Driver
  2. GODRIVER-1697

Cursor.Close accepts context which could result in cancelling the close operation

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Works as Designed
    • Icon: Major - P3 Major - P3
    • None
    • 1.3.5
    • None
    • None

    Description

      mongodb-go-driver accepts a context for the Cursor.CloseSession.EndSession, transaction, etc. This looks like a problem to me, as context is used for cancellation and cancelling a close operation is not really desired (Leaking the cursor).

      I can try just passing context.Background() specifically to such close methods, but that seems very error prone.

      You would often use context by taking the HTTP request context, which gets cancelled if the connection is severed for any reason, and possibly add a Mongo session on top of it if desired (UseSession). If I then just pass context.Background(), it won't use the session for those close operations which I'm not sure is correct or even going to work.

      Attachments

        Activity

          People

            divjot.arora@mongodb.com Divjot Arora (Inactive)
            shay@codeocean.com Shay Katz
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: