@@ -25,6 +25,7 @@ import (
2525 "time"
2626
2727 "github.com/dolthub/vitess/go/mysql"
28+ "github.com/dolthub/vitess/go/race"
2829 "github.com/dolthub/vitess/go/sqltypes"
2930 "github.com/dolthub/vitess/go/vt/proto/query"
3031 "github.com/stretchr/testify/assert"
@@ -743,6 +744,9 @@ func TestHandlerKill(t *testing.T) {
743744}
744745
745746func TestHandlerKillQuery (t * testing.T ) {
747+ if race .Enabled {
748+ t .Skip ("this test is inherently racey" )
749+ }
746750 require := require .New (t )
747751 e , pro := setupMemDB (require )
748752 dbFunc := pro .Database
@@ -785,7 +789,7 @@ func TestHandlerKillQuery(t *testing.T) {
785789
786790 var wg sync.WaitGroup
787791 wg .Add (1 )
788- sleepQuery := "SELECT SLEEP(100 )"
792+ sleepQuery := "SELECT SLEEP(1 )"
789793 go func () {
790794 defer wg .Done ()
791795 err = handler .ComQuery (context .Background (), conn1 , sleepQuery , func (res * sqltypes.Result , more bool ) error {
@@ -800,9 +804,16 @@ func TestHandlerKillQuery(t *testing.T) {
800804 // 1, , , test, Query, 0, ... , SELECT SLEEP(1000)
801805 // 2, , , test, Query, 0, running, SHOW PROCESSLIST
802806 require .Equal (2 , len (res .Rows ))
803- sleepQueryID = res .Rows [0 ][0 ].ToString ()
804- require .Equal ("Query" , res .Rows [0 ][4 ].ToString ())
805- require .Equal (sleepQuery , res .Rows [0 ][7 ].ToString ())
807+ hasSleepQuery := false
808+ for _ , row := range res .Rows {
809+ if row [7 ].ToString () != sleepQuery {
810+ continue
811+ }
812+ hasSleepQuery = true
813+ sleepQueryID = row [0 ].ToString ()
814+ require .Equal ("Query" , row [4 ].ToString ())
815+ }
816+ require .True (hasSleepQuery )
806817 return nil
807818 })
808819 require .NoError (err )
@@ -812,19 +823,26 @@ func TestHandlerKillQuery(t *testing.T) {
812823 return nil
813824 })
814825 require .NoError (err )
826+ wg .Wait ()
815827
816828 time .Sleep (100 * time .Millisecond )
817829 err = handler .ComQuery (context .Background (), conn2 , "SHOW PROCESSLIST" , func (res * sqltypes.Result , more bool ) error {
818830 // 1, , , test, Sleep, 0, ,
819831 // 2, , , test, Query, 0, running, SHOW PROCESSLIST
820832 require .Equal (2 , len (res .Rows ))
821- require .Equal ("Sleep" , res .Rows [0 ][4 ].ToString ())
822- require .Equal ("" , res .Rows [0 ][7 ].ToString ())
833+ hasSleepQueryID := false
834+ for _ , row := range res .Rows {
835+ if row [0 ].ToString () != sleepQueryID {
836+ continue
837+ }
838+ hasSleepQueryID = true
839+ require .Equal ("Sleep" , row [4 ].ToString ())
840+ require .Equal ("" , row [7 ].ToString ())
841+ }
842+ require .True (hasSleepQueryID )
823843 return nil
824844 })
825- require .NoError (err )
826-
827- wg .Wait ()
845+ require.NoError (err )g
828846
829847 require .False (conn1 .Conn .(* mockConn ).closed )
830848 require .False (conn2 .Conn .(* mockConn ).closed )
0 commit comments