From 0d8ca1be54ec50feda41b75e750619df15c5b747 Mon Sep 17 00:00:00 2001 From: Rafer Hazen Date: Wed, 22 May 2024 16:41:41 -0600 Subject: [PATCH] Improve WaitForPos errors, don't include Result struct in message (#15962) Signed-off-by: Rafer Hazen --- go/vt/vttablet/tabletmanager/vreplication/engine.go | 6 ++++-- go/vt/vttablet/tabletmanager/vreplication/engine_test.go | 5 +++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/go/vt/vttablet/tabletmanager/vreplication/engine.go b/go/vt/vttablet/tabletmanager/vreplication/engine.go index abbec84aa2f..54902928e02 100644 --- a/go/vt/vttablet/tabletmanager/vreplication/engine.go +++ b/go/vt/vttablet/tabletmanager/vreplication/engine.go @@ -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. diff --git a/go/vt/vttablet/tabletmanager/vreplication/engine_test.go b/go/vt/vttablet/tabletmanager/vreplication/engine_test.go index 6d34c52df4e..ea46e126895 100644 --- a/go/vt/vttablet/tabletmanager/vreplication/engine_test.go +++ b/go/vt/vttablet/tabletmanager/vreplication/engine_test.go @@ -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{{ @@ -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:") }