Skip to content

Commit

Permalink
Fix flakiness in TestSemiSyncRequiredWithTwoPC (#17332)
Browse files Browse the repository at this point in the history
Signed-off-by: Manan Gupta <[email protected]>
  • Loading branch information
GuptaManan100 authored Dec 9, 2024
1 parent 775ec98 commit 250148e
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion go/test/endtoend/transaction/twopc/twopc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1353,7 +1353,6 @@ func TestSemiSyncRequiredWithTwoPC(t *testing.T) {
out, err := clusterInstance.VtctldClientProcess.ExecuteCommandWithOutput("SetKeyspaceDurabilityPolicy", keyspaceName, "--durability-policy=none")
require.NoError(t, err, out)
defer func() {
clusterInstance.VtctldClientProcess.ExecuteCommandWithOutput("SetKeyspaceDurabilityPolicy", keyspaceName, "--durability-policy=semi_sync")
for _, shard := range clusterInstance.Keyspaces[0].Shards {
clusterInstance.VtctldClientProcess.PlannedReparentShard(keyspaceName, shard.Name, shard.Vttablets[0].Alias)
}
Expand All @@ -1376,6 +1375,21 @@ func TestSemiSyncRequiredWithTwoPC(t *testing.T) {
_, err = utils.ExecAllowError(t, conn, "commit")
require.Error(t, err)
require.ErrorContains(t, err, "two-pc is enabled, but semi-sync is not")

_, err = clusterInstance.VtctldClientProcess.ExecuteCommandWithOutput("SetKeyspaceDurabilityPolicy", keyspaceName, "--durability-policy=semi_sync")
require.NoError(t, err)
for _, shard := range clusterInstance.Keyspaces[0].Shards {
err = clusterInstance.VtctldClientProcess.PlannedReparentShard(keyspaceName, shard.Name, shard.Vttablets[1].Alias)
require.NoError(t, err)
}

// Transaction should now succeed.
utils.Exec(t, conn, "begin")
utils.Exec(t, conn, "insert into twopc_t1(id, col) values(4, 4)")
utils.Exec(t, conn, "insert into twopc_t1(id, col) values(6, 4)")
utils.Exec(t, conn, "insert into twopc_t1(id, col) values(9, 4)")
_, err = utils.ExecAllowError(t, conn, "commit")
require.NoError(t, err)
}

// TestReadTransactionStatus tests that read transaction state rpc works as expected.
Expand Down

0 comments on commit 250148e

Please sign in to comment.