Skip to content

Commit

Permalink
Fix conflicts
Browse files Browse the repository at this point in the history
Signed-off-by: Rohit Nayak <rohit@planetscale.com>
  • Loading branch information
rohit-nayak-ps committed Aug 27, 2024
1 parent 31212ca commit 8d1a374
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 77 deletions.
6 changes: 3 additions & 3 deletions go/vt/vttablet/tabletmanager/vreplication/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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()) {
Expand All @@ -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
Expand Down
74 changes: 0 additions & 74 deletions go/vt/vttablet/tabletmanager/vreplication/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 8d1a374

Please sign in to comment.