-
Type: Bug
-
Resolution: Fixed
-
Priority: Unknown
-
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.