Fix cases where net conn write failure was not marking connection as dead
Also added loop to run these timing sensitive tests multiple times.
This commit is contained in:
@@ -483,6 +483,7 @@ func (c *Conn) Prepare(name, sql string) (ps *PreparedStatement, err error) {
|
||||
|
||||
_, err = c.conn.Write(wbuf.buf)
|
||||
if err != nil {
|
||||
c.die(err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -544,6 +545,7 @@ func (c *Conn) Deallocate(name string) (err error) {
|
||||
|
||||
_, err = c.conn.Write(wbuf.buf)
|
||||
if err != nil {
|
||||
c.die(err)
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
@@ -229,6 +229,9 @@ func TestPoolAcquireAndReleaseCycleAutoConnect(t *testing.T) {
|
||||
func TestPoolReleaseDiscardsDeadConnections(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
// Run timing sensitive test many times
|
||||
for i := 0; i < 50; i++ {
|
||||
func() {
|
||||
maxConnections := 3
|
||||
pool := createConnPool(t, maxConnections)
|
||||
defer pool.Close()
|
||||
@@ -288,6 +291,8 @@ func TestPoolReleaseDiscardsDeadConnections(t *testing.T) {
|
||||
if stat.AvailableConnections != 0 {
|
||||
t.Fatalf("Unexpected AvailableConnections: %v", stat.CurrentConnections)
|
||||
}
|
||||
}()
|
||||
}
|
||||
}
|
||||
|
||||
func TestConnPoolTransaction(t *testing.T) {
|
||||
|
||||
+6
-1
@@ -945,6 +945,9 @@ func TestFatalRxError(t *testing.T) {
|
||||
func TestFatalTxError(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
// Run timing sensitive test many times
|
||||
for i := 0; i < 50; i++ {
|
||||
func() {
|
||||
conn := mustConnect(t, *defaultConnConfig)
|
||||
defer closeConn(t, conn)
|
||||
|
||||
@@ -965,7 +968,9 @@ func TestFatalTxError(t *testing.T) {
|
||||
}
|
||||
|
||||
if conn.IsAlive() {
|
||||
t.Fatal("Connection should not be live but was")
|
||||
t.Fatalf("Connection should not be live but was. Previous Query err: %v", err)
|
||||
}
|
||||
}()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user