Skip to content
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

database/sql: Register is not thread safe #9847

Closed
fabiokung opened this issue Feb 11, 2015 · 4 comments
Closed

database/sql: Register is not thread safe #9847

fabiokung opened this issue Feb 11, 2015 · 4 comments
Milestone

Comments

@fabiokung
Copy link

sql.Register can't currently be called from multiple goroutines:

https://github.com/golang/go/blob/f58a5cb9e2/src/database/sql/sql.go#L28-L39

It should do something along the lines of gob.RegisterName and synchronize access on the global drivers registry:

go/src/encoding/gob/type.go

Lines 823 to 824 in f58a5cb

registerLock.Lock()
defer registerLock.Unlock()

@bradfitz
Copy link
Contributor

Or we just document it.

@bradfitz bradfitz added this to the Go1.5 milestone Feb 11, 2015
@fabiokung
Copy link
Author

Or we just document it.

sgtm

@mikioh mikioh changed the title sql.Register (database/sql) is not thread safe database/sql: Register is not thread safe Feb 15, 2015
@bradfitz
Copy link
Contributor

Actually it was easier to just add a mutex than document it.

@gopherbot
Copy link

CL https://golang.org/cl/11682 mentions this issue.

@golang golang locked and limited conversation to collaborators Jun 29, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants