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

Data race when fetching the number of sessions in progress

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

      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@mongodb.com Benji Rewis (Inactive)
            Reporter:
            inovakov@gmail.com Ivaylo Novakov
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: