From 6e95dd05de733e962469fa94e14cd79e08162511 Mon Sep 17 00:00:00 2001 From: Manan Gupta <35839558+GuptaManan100@users.noreply.github.com> Date: Fri, 14 Jul 2023 00:13:50 +0530 Subject: [PATCH 1/2] Fix `TestGatewayBufferingWhileReparenting` flakiness (#13469) * feat: fix gateway reparent flakiness Signed-off-by: Manan Gupta * feat: verify the consistant state Signed-off-by: Manan Gupta --------- Signed-off-by: Manan Gupta --- go/vt/vtgate/tabletgateway_flaky_test.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/go/vt/vtgate/tabletgateway_flaky_test.go b/go/vt/vtgate/tabletgateway_flaky_test.go index 34bb65363be..3e9d4102cf5 100644 --- a/go/vt/vtgate/tabletgateway_flaky_test.go +++ b/go/vt/vtgate/tabletgateway_flaky_test.go @@ -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}) From 8a9ac4887ed95ff59c22432730b973049312de80 Mon Sep 17 00:00:00 2001 From: Manan Gupta Date: Fri, 14 Jul 2023 20:09:39 +0530 Subject: [PATCH 2/2] feat: fix test Signed-off-by: Manan Gupta --- go/vt/vtgate/tabletgateway_flaky_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go/vt/vtgate/tabletgateway_flaky_test.go b/go/vt/vtgate/tabletgateway_flaky_test.go index 3e9d4102cf5..ebad7d4aa90 100644 --- a/go/vt/vtgate/tabletgateway_flaky_test.go +++ b/go/vt/vtgate/tabletgateway_flaky_test.go @@ -191,7 +191,7 @@ func TestGatewayBufferingWhileReparenting(t *testing.T) { hc.Broadcast(primaryTablet) require.Len(t, tg.hc.GetHealthyTabletStats(target), 0, "GetHealthyTabletStats has tablets even though it shouldn't") - _, isNotServing := tg.kev.PrimaryIsNotServing(target) + isNotServing := tg.kev.PrimaryIsNotServing(target) require.True(t, isNotServing) // add a result to the sandbox connection of the new primary