Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fuzzer testing for 2PC transactions #16476

Merged
merged 11 commits into from
Jul 29, 2024
Prev Previous commit
Next Next commit
test: rollback transactions if any query fails
Signed-off-by: Manan Gupta <manan@planetscale.com>
  • Loading branch information
GuptaManan100 committed Jul 25, 2024
commit 8d9f8c76256582497adaba490d725f92e3ac2b88
12 changes: 9 additions & 3 deletions go/test/endtoend/transaction/twopc/fuzzer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func TestTwoPCFuzzTest(t *testing.T) {
},
{
name: "Multiple Threads - Single Set",
threads: 5,
threads: 2,
updateSets: 1,
timeForTesting: 5 * time.Second,
},
Expand Down Expand Up @@ -264,11 +264,17 @@ func (fz *fuzzer) generateAndExecuteTransaction(t *testing.T, conn *mysql.Conn,
queries = append(queries, fz.generateInsertQueries(updateSetVal, threadId)...)
_, err := conn.ExecuteFetch("begin", 0, false)
require.NoError(t, err)
finalCommand := "commit"
for _, query := range queries {
_, _ = conn.ExecuteFetch(query, 0, false)
_, err = conn.ExecuteFetch(query, 0, false)
// If any command fails because of deadlocks or timeout or whatever, then we need to rollback the transaction.
if err != nil {
finalCommand = "rollback"
break
}
}
// TODO: Check if we want to randomize commit and rollback decisions.
_, _ = conn.ExecuteFetch("commit", 0, false)
_, _ = conn.ExecuteFetch(finalCommand, 0, false)
}

// generateUpdateQueries generates the queries to run updates on the twopc_fuzzer_update table.
Expand Down
Loading