alexbrainman / odbc

odbc driver written in go
BSD 3-Clause "New" or "Revised" License
352 stars 140 forks source link

Bad connections discovered during Tx.Commit or Tx.Rollback get reused in future transactions. #58

Closed ChrisHines closed 9 years ago

ChrisHines commented 9 years ago

Although this is probably a bug in database/sql (https://github.com/golang/go/issues/11264), it has been around for a long time and may not get fixed there since other drivers are unaffected or have already worked around the issue. Even if it is fixed in the next release of Go, we may want to fix it here to work correctly with Go 1.5 and earlier.

alexbrainman commented 9 years ago

Do you have a plan? I had a look at what github.com/lib/pq have done here - mark connections as bad and check for bad connection before doing any work. We can do the same, I guess. Do you have test for this? I am bit busy at this moment, but I will try to make time for this. Thank you.

Alex

ChrisHines commented 9 years ago

@alexbrainman I am working on a fix along those lines exactly. I have a test and fix implemented locally, but I'm not ready to make a PR yet because I have found another odd behavior and I am still chasing that down.

Also, as part of this exercise I have discovered that odbc.Conn.Close could leak handles if it encounters errors. My fix should take care of that as well.

ChrisHines commented 9 years ago

It turns out the "other odd behavior" is https://github.com/golang/go/issues/10886, which is separate.

ChrisHines commented 9 years ago

My CL to fix this in database/sql was just merged and should be in Go 1.6. https://golang.org/cl/13912.

Still working on fix in the driver that works with Go 1.5 and earlier.

alexbrainman commented 9 years ago

Cool.

Alex