From 8d1a374312ea8870d9cae965f9c791ab53626e57 Mon Sep 17 00:00:00 2001 From: Rohit Nayak Date: Tue, 27 Aug 2024 10:45:24 +0200 Subject: [PATCH] Fix conflicts Signed-off-by: Rohit Nayak --- .../tabletmanager/vreplication/utils.go | 6 +- .../tabletmanager/vreplication/utils_test.go | 74 ------------------- 2 files changed, 3 insertions(+), 77 deletions(-) diff --git a/go/vt/vttablet/tabletmanager/vreplication/utils.go b/go/vt/vttablet/tabletmanager/vreplication/utils.go index f1bc75e1490..9bdabeaf312 100644 --- a/go/vt/vttablet/tabletmanager/vreplication/utils.go +++ b/go/vt/vttablet/tabletmanager/vreplication/utils.go @@ -21,6 +21,9 @@ import ( "fmt" "strconv" + vtrpcpb "vitess.io/vitess/go/vt/proto/vtrpc" + "vitess.io/vitess/go/vt/vterrors" + "vitess.io/vitess/go/constants/sidecar" "vitess.io/vitess/go/mysql/sqlerror" "vitess.io/vitess/go/sqltypes" @@ -123,8 +126,6 @@ func isUnrecoverableError(err error) bool { if err == nil { return false } -<<<<<<< HEAD -======= switch vterrors.Code(err) { case vtrpcpb.Code_FAILED_PRECONDITION: if vterrors.RxWrongTablet.MatchString(err.Error()) { @@ -133,7 +134,6 @@ func isUnrecoverableError(err error) bool { } return true } ->>>>>>> d1d6bd8864 (VReplication workflows: retry "wrong tablet type" errors (#16645)) sqlErr, isSQLErr := sqlerror.NewSQLErrorFromError(err).(*sqlerror.SQLError) if !isSQLErr { return false diff --git a/go/vt/vttablet/tabletmanager/vreplication/utils_test.go b/go/vt/vttablet/tabletmanager/vreplication/utils_test.go index eb2b128f90e..c00ed34a4d6 100644 --- a/go/vt/vttablet/tabletmanager/vreplication/utils_test.go +++ b/go/vt/vttablet/tabletmanager/vreplication/utils_test.go @@ -18,90 +18,16 @@ package vreplication import ( "errors" - "fmt" - "strings" "testing" "github.com/stretchr/testify/require" "vitess.io/vitess/go/mysql/sqlerror" - "vitess.io/vitess/go/sqltypes" - "vitess.io/vitess/go/textutil" - "vitess.io/vitess/go/vt/binlog/binlogplayer" "vitess.io/vitess/go/vt/vterrors" - binlogdatapb "vitess.io/vitess/go/vt/proto/binlogdata" vtrpcpb "vitess.io/vitess/go/vt/proto/vtrpc" ) -func TestInsertLogTruncation(t *testing.T) { - dbClient := binlogplayer.NewMockDBClient(t) - defer dbClient.Close() - dbClient.RemoveInvariant("insert into _vt.vreplication_log") // Otherwise the insert will be ignored - stats := binlogplayer.NewStats() - defer stats.Stop() - vdbClient := newVDBClient(dbClient, stats) - defer vdbClient.Close() - vrID := int32(1) - typ := "Testing" - state := binlogdatapb.VReplicationWorkflowState_Error.String() - - insertStmtf := "insert into _vt.vreplication_log(vrepl_id, type, state, message) values(%d, '%s', '%s', %s)" - - tests := []struct { - message string - expectTruncation bool - }{ - { - message: "Simple message that's not truncated", - }, - { - message: "Simple message that needs to be truncated " + strings.Repeat("a", 80000) + " cuz it's long", - expectTruncation: true, - }, - { - message: "Simple message that doesn't need to be truncated " + strings.Repeat("b", 64000) + " cuz it's not quite too long", - }, - { - message: "Message that is just barely short enough " + strings.Repeat("c", maxVReplicationLogMessageLen-(len("Message that is just barely short enough ")+len(" so it doesn't get truncated"))) + " so it doesn't get truncated", - }, - { - message: "Message that is just barely too long " + strings.Repeat("d", maxVReplicationLogMessageLen-(len("Message that is just barely too long ")+len(" so it gets truncated"))+1) + " so it gets truncated", - expectTruncation: true, - }, - { - message: "Super long message brosef wut r ya doin " + strings.Repeat("e", 60000) + strings.Repeat("f", 60000) + " so maybe don't do that to yourself and your friends", - expectTruncation: true, - }, - { - message: "Super duper long message brosef wut r ya doin " + strings.Repeat("g", 120602) + strings.Repeat("h", 120001) + " so maybe really don't do that to yourself and your friends", - expectTruncation: true, - }, - } - for _, tc := range tests { - t.Run("insertLog", func(t *testing.T) { - var ( - messageOut string - err error - ) - if tc.expectTruncation { - messageOut, err = textutil.TruncateText(tc.message, maxVReplicationLogMessageLen, binlogplayer.TruncationLocation, binlogplayer.TruncationIndicator) - require.NoError(t, err) - require.True(t, strings.HasPrefix(messageOut, tc.message[:1024])) // Confirm we still have the same beginning - require.True(t, strings.HasSuffix(messageOut, tc.message[len(tc.message)-1024:])) // Confirm we still have the same end - require.True(t, strings.Contains(messageOut, binlogplayer.TruncationIndicator)) // Confirm we have the truncation text - t.Logf("Original message length: %d, truncated message length: %d", len(tc.message), len(messageOut)) - } else { - messageOut = tc.message - } - require.LessOrEqual(t, len(messageOut), maxVReplicationLogMessageLen) - dbClient.ExpectRequest(fmt.Sprintf(insertStmtf, vrID, typ, state, encodeString(messageOut)), &sqltypes.Result{}, nil) - insertLog(vdbClient, typ, vrID, state, tc.message) - dbClient.Wait() - }) - } -} - // TestIsUnrecoverableError tests the different error cases for isUnrecoverableError(). func TestIsUnrecoverableError(t *testing.T) { if runNoBlobTest {