Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-36294

Sum of currentActive and currentInactive not equal to currentOpen transactions

    XMLWordPrintableJSON

Details

    • Fully Compatible
    • ALL
    • v4.0
    • Repl 2018-08-13

    Description

      Small inaccuracies due to skew might be expected because the counter updates aren't atomic, but this looks to me to be much larger than that, as if the transaction is spending significant time between between corresponding updates to the counters.

      This was a simple test with 10 threads doing transactional updates to single independent documents:

      function repro() {
       
          nthreads = 10
       
          db.createCollection("c", {writeConcern: {w: "majority"}})
       
          threads = []
          for (var t=0; t<nthreads; t++) {
              thread = new ScopedThread((t) =>  {
                  var ses = db.getMongo().startSession()
                  ses.getDatabase("test").c.insert({_id: t, i: 0})
                  for (;;) {
                      try {
                          ses.startTransaction()
                          ses.getDatabase("test").c.update({_id: t}, {$inc: {i: 1}})
                          //if (t==0) sleep(1000)
                          ses.commitTransaction()
                      } catch (e) {
                          print(e)
                      }
                  }
              }, t)
              threads.push(thread)
              thread.start()
          }
          for (var t = 0; t < nthreads; t++)
              threads[t].join()
      }
      

      Attachments

        Issue Links

          Activity

            People

              nathan.louie Nathan Louie
              bruce.lucas@mongodb.com Bruce Lucas (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              11 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: