Skip to content

Fix data race in 'discard connections' pool test.#1860

Merged
matthewdale merged 1 commit into
mongodb:masterfrom
matthewdale:fix-discard-connections-race
Oct 14, 2024
Merged

Fix data race in 'discard connections' pool test.#1860
matthewdale merged 1 commit into
mongodb:masterfrom
matthewdale:fix-discard-connections-race

Conversation

@matthewdale

Copy link
Copy Markdown
Contributor

Summary

  • Don't share the err variable in the goroutine closure (pool_test.go line 893) to prevent a data race.
  • Enable the race detector in the test-short Taskfile target.

Background & Motivation

The race detector panics because of a data race in the "discards connections closed by the server side" connection pool test:

WARNING: DATA RACE
Read at 0x00c0005f4aa0 by goroutine 4142:
  go.mongodb.org/mongo-driver/v2/x/mongo/driver/topology.TestPool_checkOut.func10.3()
      /Users/matt.dale/work/mongo-go-driver/x/mongo/driver/topology/pool_test.go:897 +0x1b0

Previous write at 0x00c0005f4aa0 by goroutine 3796:
  go.mongodb.org/mongo-driver/v2/x/mongo/driver/topology.TestPool_checkOut.func10()
      /Users/matt.dale/work/mongo-go-driver/x/mongo/driver/topology/pool_test.go:907 +0x90c
...

@mongodb-drivers-pr-bot mongodb-drivers-pr-bot Bot added the review-priority-low Low Priority PR for Review: within 3 business days label Oct 11, 2024
@mongodb-drivers-pr-bot

Copy link
Copy Markdown
Contributor

API Change Report

No changes found!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review-priority-low Low Priority PR for Review: within 3 business days

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants