Skip to content

Commit

Permalink
Fix TestGatewayBufferingWhileReparenting flakiness (#13469) (#13499)
Browse files Browse the repository at this point in the history
* feat: fix gateway reparent flakiness



* feat: verify the consistant state



---------

Signed-off-by: Manan Gupta <[email protected]>
  • Loading branch information
GuptaManan100 authored Jul 17, 2023
1 parent 217a0d2 commit dddeb6a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions go/vt/vtgate/tabletgateway_flaky_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,14 @@ func TestGatewayBufferingWhileReparenting(t *testing.T) {
hc.Broadcast(primaryTablet)
// set the serving type for the primary tablet false and broadcast it so that the buffering code registers this change
hc.SetServing(primaryTablet, false)
// We call the broadcast twice to ensure that the change has been processed by the keyspace event watcher.
// The second broadcast call is blocking until the first one has been processed.
hc.Broadcast(primaryTablet)
hc.Broadcast(primaryTablet)

require.Len(t, tg.hc.GetHealthyTabletStats(target), 0, "GetHealthyTabletStats has tablets even though it shouldn't")
_, isNotServing := tg.kev.PrimaryIsNotServing(target)
require.True(t, isNotServing)

// add a result to the sandbox connection of the new primary
sbcReplica.SetResults([]*sqltypes.Result{sqlResult1})
Expand All @@ -197,8 +204,6 @@ func TestGatewayBufferingWhileReparenting(t *testing.T) {
queryChan <- struct{}{}
}()

require.Len(t, tg.hc.GetHealthyTabletStats(target), 0, "GetHealthyTabletStats has tablets even though it shouldn't")

// set the serving type for the new primary tablet true and broadcast it so that the buffering code registers this change
// this should stop the buffering and the query executed in the go routine should work. This should be done with some delay so
// that we know that the query was buffered
Expand Down

0 comments on commit dddeb6a

Please sign in to comment.