Skip to content

Commit

Permalink
Lower flakiness by using longer tx timeouts
Browse files Browse the repository at this point in the history
Signed-off-by: Florent Poinsard <florent.poinsard@outlook.fr>
  • Loading branch information
frouioui committed Feb 14, 2025
1 parent 7135534 commit 512cc5c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
18 changes: 9 additions & 9 deletions go/test/endtoend/reparent/newfeaturetest/reparent_in_tx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ func testCommitError(t *testing.T, conn *mysql.Conn, clusterInstance *cluster.Lo
tabletStopped := make(chan bool)
commitDone := make(chan bool)
idx := 1
createTxAndInsertRows(conn, t, idx)

go func() {
createTxAndInsertRows(conn, t, idx)
<-tabletStopped
time.Sleep(1 * time.Second)
_, err := conn.ExecuteFetch("commit", 0, false)
require.ErrorContains(t, err, vterrors.VT15001(0).ID)
commitDone <- true
Expand All @@ -59,9 +59,9 @@ func testExecuteError(t *testing.T, conn *mysql.Conn, clusterInstance *cluster.L
tabletStopped := make(chan bool)
executeDone := make(chan bool)
idx := 1
go func() {
createTxAndInsertRows(conn, t, idx)
createTxAndInsertRows(conn, t, idx)

go func() {
idx += 5
<-tabletStopped
_, err := conn.ExecuteFetch(utils.GetInsertMultipleValuesQuery(idx, idx+1, idx+2, idx+3), 0, false)
Expand Down Expand Up @@ -103,15 +103,11 @@ func reparent(t *testing.T, clusterInstance *cluster.LocalProcessCluster, tablet
output, err := utils.Prs(t, clusterInstance, tablets[prsTo])
require.NoError(t, err, "error in PlannedReparentShard output - %s", output)

time.Sleep(5 * time.Second)

// We now restart the vttablet that became a replica.
utils.StopTablet(t, tablets[primary], false)
tabletStopped <- true
primary = prsTo

time.Sleep(5 * time.Second)

// Wait for the action triggering the VT15001 to be done before moving on
<-actionDone

Expand All @@ -122,7 +118,11 @@ func reparent(t *testing.T, clusterInstance *cluster.LocalProcessCluster, tablet
}

func TestErrorsInTransaction(t *testing.T) {
clusterInstance := utils.SetupShardedReparentCluster(t, policy.DurabilitySemiSync)
clusterInstance := utils.SetupShardedReparentCluster(t, policy.DurabilitySemiSync, map[string]string{
"--queryserver-config-transaction-timeout": "5m",
"--queryserver-config-query-timeout": "5m",
})

defer utils.TeardownCluster(clusterInstance)

keyspace := clusterInstance.Keyspaces[0]
Expand Down
2 changes: 1 addition & 1 deletion go/test/endtoend/reparent/newfeaturetest/reparent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ func TestERSWithWriteInPromoteReplica(t *testing.T) {
}

func TestBufferingWithMultipleDisruptions(t *testing.T) {
clusterInstance := utils.SetupShardedReparentCluster(t, policy.DurabilitySemiSync)
clusterInstance := utils.SetupShardedReparentCluster(t, policy.DurabilitySemiSync, nil)
defer utils.TeardownCluster(clusterInstance)

// Stop all VTOrc instances, so that they don't interfere with the test.
Expand Down
6 changes: 5 additions & 1 deletion go/test/endtoend/reparent/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func SetupRangeBasedCluster(ctx context.Context, t *testing.T) *cluster.LocalPro
}

// SetupShardedReparentCluster is used to setup a sharded cluster for testing
func SetupShardedReparentCluster(t *testing.T, durability string) *cluster.LocalProcessCluster {
func SetupShardedReparentCluster(t *testing.T, durability string, extraVttabletFlags map[string]string) *cluster.LocalProcessCluster {
clusterInstance := cluster.NewCluster(cell1, Hostname)
// Start topo server
err := clusterInstance.StartTopo()
Expand All @@ -89,6 +89,10 @@ func SetupShardedReparentCluster(t *testing.T, durability string) *cluster.Local
"--health_check_interval", "1s",
"--track_schema_versions=true",
"--queryserver_enable_online_ddl=false")
for flag, val := range extraVttabletFlags {
clusterInstance.VtTabletExtraArgs = append(clusterInstance.VtTabletExtraArgs, flag, val)
}

clusterInstance.VtGateExtraArgs = append(clusterInstance.VtGateExtraArgs,
"--enable_buffer",
// Long timeout in case failover is slow.
Expand Down

0 comments on commit 512cc5c

Please sign in to comment.