diff --git a/go/vt/vttablet/tabletmanager/vreplication/utils.go b/go/vt/vttablet/tabletmanager/vreplication/utils.go index 75ad4b95552..789c034bfa3 100644 --- a/go/vt/vttablet/tabletmanager/vreplication/utils.go +++ b/go/vt/vttablet/tabletmanager/vreplication/utils.go @@ -107,11 +107,11 @@ func insertLog(dbClient *vdbClient, typ string, vreplID int32, state, message st maxMessageLen := 65535 truncationStr := fmt.Sprintf(" ... %s ... ", sqlparser.TruncationText) if len(message) > maxMessageLen { - mid := ((len(message) / 2) - len(truncationStr)) - 1 + mid := (len(message) / 2) - len(truncationStr) for mid > (maxMessageLen / 2) { mid = mid / 2 } - tail := (len(message) - mid + len(truncationStr)) + tail := (len(message) - (mid + len(truncationStr))) + 1 message = fmt.Sprintf("%s%s%s", message[:mid], truncationStr, message[tail:]) } buf.Myprintf("insert into %s.vreplication_log(vrepl_id, type, state, message) values(%s, %s, %s, %s)", diff --git a/go/vt/vttablet/tabletmanager/vreplication/utils_test.go b/go/vt/vttablet/tabletmanager/vreplication/utils_test.go index 7b3698c53e7..cf296d5fb2c 100644 --- a/go/vt/vttablet/tabletmanager/vreplication/utils_test.go +++ b/go/vt/vttablet/tabletmanager/vreplication/utils_test.go @@ -25,7 +25,6 @@ import ( "vitess.io/vitess/go/sqltypes" "vitess.io/vitess/go/vt/binlog/binlogplayer" - "vitess.io/vitess/go/vt/log" "vitess.io/vitess/go/vt/sqlparser" binlogdatapb "vitess.io/vitess/go/vt/proto/binlogdata" @@ -81,7 +80,6 @@ func TestInsertLogTruncation(t *testing.T) { t.Run("insertLog", func(t *testing.T) { var messageOut string if tc.expectTruncation { - log.Errorf("BEFORE:: Message length: %d", len(tc.message)) mid := (len(tc.message) / 2) - len(truncationStr) for mid > (maxMessageLen / 2) { mid = mid / 2