Skip to content

Commit

Permalink
Check for multi-db commit failed warning
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 db8249e commit 83dba75
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion go/test/endtoend/reparent/newfeaturetest/reparent_in_tx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package newfeaturetest

import (
"context"
"strings"
"testing"
"time"

Expand Down Expand Up @@ -49,8 +50,21 @@ func testCommitError(t *testing.T, conn *mysql.Conn, clusterInstance *cluster.Lo

reparent(t, clusterInstance, tablets, tabletStopped, commitDone)

// we may run in a situation where we first commit on a healthy shard, in which case we would run in a multi-db commit
// warning, in this situation, we cannot proceed with the select asserting that no rows are returned as there will be
// commited inserts on healthy shards.
r, err := conn.ExecuteFetch("show warnings", 100, false)
require.NoError(t, err)
for _, row := range r.Rows {
if len(row) == 3 && strings.Contains(row[2].ToString(), "mutli-db commit failed") {
_, err = conn.ExecuteFetch("delete * from vt_insert_test", 0, false)
require.NoError(t, err)
return
}
}

// if the unhealthy shard is the first one where we commited, let's assert that the table is empty on all the shards
r, err := conn.ExecuteFetch("select * from vt_insert_test", 1, false)
r, err = conn.ExecuteFetch("select * from vt_insert_test", 1, false)
require.NoError(t, err)
require.Len(t, r.Rows, 0)
}
Expand Down

0 comments on commit 83dba75

Please sign in to comment.