Data race when fetching the number of sessions in progress

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Fixed
    • Priority: Unknown
    • 1.10.3
    • Affects Version/s: None
    • Component/s: None
    • None
    • None
    • Not Needed
    • None
    • None
    • None
    • None
    • None
    • None

      Summary

      Calling db.Client().NumberSessionsInProgress() from one goroutine triggers the data race detector when other goroutines are working with the database calling CountDocuments() or other operation.

      Please provide the version of the driver. If applicable, please provide the MongoDB server version and topology (standalone, replica set, or sharded cluster).

      Driver version  v1.10.1.

      Topology: replica set with a single server.

      How to Reproduce

      Steps to reproduce. If possible, please include a Short, Self Contained, Correct (Compilable), Example.

       

      func TestDataRace(t *testing.T) {
          ctx := context.Background()
          connStr := database.ConnectionString(test.DBTestCredentials())
          c, _ := mongo.NewClient(options.Client().ApplyURI(connStr))
          _ = c.Connect(ctx)
          db := c.Database("races")}}{{    go func() {
              for {
                  _ = db.Client().NumberSessionsInProgress()
              }
          }()
          go func() {
              for {
                  _, _ = db.Collection("users").CountDocuments(ctx, bson.M{})
              }
          }()
          time.Sleep(time.Second)
      }
      

      Additional Background

      Please provide any additional background information that may be helpful in diagnosing the bug.

            Assignee:
            Benji Rewis (Inactive)
            Reporter:
            Ivaylo Novakov
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: