Skip to content

GODRIVER-2109 Prevent a data race between connecting and checking out a connection from the resourcePool. #726

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

matthewdale
Copy link
Collaborator

@matthewdale matthewdale commented Sep 1, 2021

GODRIVER-2109

There is currently a data race on the field connection.desc between setting it at connection.go#L231 and reading it at pool.go#L199 and pool.go#L535. The data race occurs when the resourcePool.Maintain() function adds connections to satisfy minPoolSize (only when minPoolSize > 0). The unconnected connections are added to the resourcePool and then connected in a separate goroutine, which results in concurrent access to the connection.desc field when another goroutine attempts to get the connection from the resourcePool.

Changes:

  • Update resourcePool.Maintain() and pool.connectionInitFunc() to wait for a connection to finish connecting before making it available to check out from the resourcePool.
  • Add a test that triggers the data race when run with the data race detector enabled.

@matthewdale matthewdale force-pushed the godriver2109-fix-stale-race branch from e688c4b to 9127e97 Compare September 1, 2021 00:51
@matthewdale
Copy link
Collaborator Author

Closing in favor of #728

@matthewdale matthewdale closed this Sep 1, 2021
@matthewdale matthewdale deleted the godriver2109-fix-stale-race branch September 1, 2021 21:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant