ExportXMLWordPrintableJSON

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • None
    • Ruby Drivers
    • Not Needed
    • None
    • None
    • None
    • None
    • None
    • None

      With tracing enabled, the tracer keeps per-client state that is not always cleaned up, so long-running processes grow over time.

      1. Cursors not read to the end. Every new cursor stores its context in cursor_context_map, and the entry is removed only when a getMore returns cursor id 0. Nothing reads the map. Reported on mongodb/mongo-ruby-driver#3108.
      2. Failed commit. commit_transaction finishes the transaction span only on success, so a commit that raises leaves the span, its context and the attached context token behind. The stale context also stays current on that thread, so later spans get the old transaction as their parent.
      3. end_session right after start_transaction. end_session aborts only when the transaction is in progress, so a transaction with no operations is never finished.

      Repro (OpenTelemetry SDK installed and configured, local replica set):

      client = Mongo::Client.new(uri, tracing:

      { enabled: true }

      )
      coll = client[:test]
      coll.insert_many(Array.new(10) { |i|

      { _id: i }

      })

      20.times { coll.find({}, batch_size: 2).first }
      client.tracer.cursor_context_map.size # => 20

      20.times do
      session = client.start_session
      session.start_transaction
      session.end_session
      end
      client.tracer.transaction_span_map.size # => 20

      The same happens for a commit that fails, including inside with_transaction.

      Two related cases are out of scope here: a session dropped without end_session leaves its transaction entries behind for good, and committing on a different thread or fiber than start_transaction detaches the context from the wrong fiber. Both come from how the transaction context is attached and need a separate design change.

            Assignee:
            Dmitry Rybakov
            Reporter:
            Dmitry Rybakov
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: