@@ -102,13 +102,36 @@ func TestDropAndRecreateWithSameShards(t *testing.T) {
102
102
103
103
cur := conn .Session (ks1 + "@primary" , nil )
104
104
105
+ mysqlConnCountBefore , err := getMySQLConnectionCount (ctx , cur )
106
+ require .Nil (t , err )
107
+
105
108
_ , err = cur .Execute (ctx , "DROP DATABASE " + ks1 , nil )
106
109
require .Nil (t , err )
107
110
108
111
_ , err = cur .Execute (ctx , "CREATE DATABASE " + ks1 , nil )
109
112
require .Nil (t , err )
110
113
111
114
assertTabletsPresent (t )
115
+
116
+ mysqlConnCountAfter , err := getMySQLConnectionCount (ctx , cur )
117
+ require .Nil (t , err )
118
+
119
+ // Assert that we're not leaking mysql connections, but allow for some wiggle room due to transient connections
120
+ assert .InDelta (t , mysqlConnCountBefore , mysqlConnCountAfter , 5 ,
121
+ "not within allowable delta: mysqlConnCountBefore=%d, mysqlConnCountAfter=%d" , mysqlConnCountBefore , mysqlConnCountAfter )
122
+ }
123
+
124
+ func getMySQLConnectionCount (ctx context.Context , session * vtgateconn.VTGateSession ) (int , error ) {
125
+ result , err := session .Execute (ctx , "SELECT COUNT(*) FROM information_schema.processlist" , nil )
126
+ if err != nil {
127
+ return 0 , err
128
+ }
129
+ row := result .Rows [0 ][0 ]
130
+ toInt , err := row .ToInt ()
131
+ if err != nil {
132
+ return 0 , err
133
+ }
134
+ return toInt , nil
112
135
}
113
136
114
137
func assertTabletsPresent (t * testing.T ) {
0 commit comments