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

Improve WaitForPos errors, don't include Result struct in message #15962

Merged
merged 3 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions go/vt/vttablet/tabletmanager/vreplication/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -790,8 +790,10 @@ func (vre *Engine) WaitForPos(ctx context.Context, id int32, pos string) error {
}
case len(qr.Rows) == 0:
return fmt.Errorf("vreplication stream %d not found", id)
case len(qr.Rows) > 1 || len(qr.Rows[0]) != 3:
return fmt.Errorf("unexpected result: %v", qr)
case len(qr.Rows) > 1:
return fmt.Errorf("vreplication stream received more rows than expected, got %d instead of 1", len(qr.Rows))
case len(qr.Rows[0]) != 3:
return fmt.Errorf("vreplication stream received an unexpected number of columns, got %d instead of 3", len(qr.Rows[0]))
}

// When err is not nil then we got a retryable error and will loop again.
Expand Down
5 changes: 3 additions & 2 deletions go/vt/vttablet/tabletmanager/vreplication/engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,8 @@ func TestWaitForPosError(t *testing.T) {

dbClient.ExpectRequest("select pos, state, message from _vt.vreplication where id=1", &sqltypes.Result{Rows: [][]sqltypes.Value{{}}}, nil)
err = vre.WaitForPos(context.Background(), 1, "MariaDB/0-1-1084")
want = "unexpected result: &{[] 0 0 [[]] 0 }"
want = "vreplication stream received an unexpected number of columns, got 0 instead of 3"

assert.EqualError(t, err, want, "WaitForPos:")

dbClient.ExpectRequest("select pos, state, message from _vt.vreplication where id=1", &sqltypes.Result{Rows: [][]sqltypes.Value{{
Expand All @@ -435,7 +436,7 @@ func TestWaitForPosError(t *testing.T) {
sqltypes.NewVarBinary("MariaDB/0-1-1083"),
}}}, nil)
err = vre.WaitForPos(context.Background(), 1, "MariaDB/0-1-1084")
want = `unexpected result: &{[] 0 0 [[VARBINARY("MariaDB/0-1-1083")] [VARBINARY("MariaDB/0-1-1083")]] 0 }`
want = "vreplication stream received more rows than expected, got 2 instead of 1"
assert.EqualError(t, err, want, "WaitForPos:")
}

Expand Down
Loading