Skip to content

Commit

Permalink
added a fix that closes a connection with a transactionthat was faile…
Browse files Browse the repository at this point in the history
…d to resume by server (denisenkom#606)
  • Loading branch information
dududko committed Sep 28, 2020
1 parent 1e08a3f commit bd24ca0
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion mssql.go
Expand Up @@ -184,13 +184,20 @@ func (c *Conn) checkBadConn(err error) error {
panic("driver.ErrBadConn in checkBadConn. This should not happen.")
}

switch err.(type) {
switch typedErr := err.(type) {
case net.Error:
c.connectionGood = false
return err
case StreamError:
c.connectionGood = false
return err
case Error:
// The server failed to resume the transaction
// Issue https://github.com/denisenkom/go-mssqldb/issues/606
if typedErr.Number == 3971 && typedErr.Class == 16 {
c.connectionGood = false
}
return err
default:
return err
}
Expand Down

0 comments on commit bd24ca0

Please sign in to comment.