Description
What version of Go are you using (go version
)?
go version go1.8.3 darwin/amd64
What did you do?
Unlike Conn
or Stmt
there's no guidance on Tx
indicating how the stdlib uses implementations. This seems to cause bugs in driver implementations, as a Tx
is expected to handle concurrent calls from multiple goroutines unlike most of the other interfaces in the package.
This came up as I was debugging a panic inside of lib/pq and discovered it was a data race due to the authors not assuming that their Tx
would have to deal with calls from multiple goroutines (the repro is here. It slowly adjusts timeouts to try and make the Context time out as results are coming back). Out of curiosity, I looked at go-sql-driver/mysql
and the lack of a race there seems like a happy accident - the Context expiring occasionally causes an internal error to bubble up, since the authors appear to aggressively check their invariants.
I'm not sure whether this is a documentation problem or if there's something database/sql could do to make life easier for driver implementors.