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

@fabiokung fabiokung commented Feb 11, 2015

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

@bradfitz bradfitz commented Feb 11, 2015

Or we just document it.

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

@fabiokung fabiokung commented Feb 11, 2015

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

@bradfitz bradfitz commented Jun 30, 2015

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

@bradfitz bradfitz removed the Documentation label Jun 30, 2015
@gopherbot
Copy link

@gopherbot gopherbot commented Jun 30, 2015

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

@bradfitz bradfitz closed this in fc2eee8 Jun 30, 2015
@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
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.