2
0

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:
Jack Christensen
2015-09-12 19:32:55 -05:00
parent bc4742b80a
commit 6e5fa60c4c
3 changed files with 83 additions and 71 deletions
+2
View File
@@ -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
}
+5
View File
@@ -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
View File
@@ -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)
}
}()
}
}