Skip to content

Commit

Permalink
Merge branch 'file_backup' into file_restore
Browse files Browse the repository at this point in the history
Conflicts:
	go.sum
  • Loading branch information
3pointer committed Jul 17, 2023
2 parents 524ef39 + 687513c commit 37e362d
Show file tree
Hide file tree
Showing 315 changed files with 28,280 additions and 23,104 deletions.
28 changes: 10 additions & 18 deletions DEPS.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -3163,14 +3163,6 @@ def go_deps():
sum = "h1:AEcvKyVM8CUII3bYzgz8haFXtGiqcrtXW1csu/5UELY=",
version = "v1.5.1-0.20230103063557-828f39b09b6d",
)
go_repository(
name = "com_github_pingcap_check",
build_file_proto_mode = "disable_global",
importpath = "github.com/pingcap/check",
sum = "h1:R8gStypOBmpnHEx1qi//SaqxJVI4inOqljg/Aj5/390=",
version = "v0.0.0-20200212061837-5e12011dc712",
)

go_repository(
name = "com_github_pingcap_errors",
build_file_proto_mode = "disable_global",
Expand All @@ -3189,8 +3181,8 @@ def go_deps():
name = "com_github_pingcap_fn",
build_file_proto_mode = "disable_global",
importpath = "github.com/pingcap/fn",
sum = "h1:Pe2LbxRmbTfAoKJ65bZLmhahmvHm7n9DUxGRQT00208=",
version = "v0.0.0-20200306044125-d5540d389059",
sum = "h1:CyA6AxcOZkQh52wIqYlAmaVmF6EvrcqFywP463pjA8g=",
version = "v1.0.0",
)
go_repository(
name = "com_github_pingcap_goleveldb",
Expand All @@ -3203,8 +3195,8 @@ def go_deps():
name = "com_github_pingcap_kvproto",
build_file_proto_mode = "disable_global",
importpath = "github.com/pingcap/kvproto",
sum = "h1:yCWc6ZivbE5Ia7VxznP4R3tW6Njgyc3Wn3ZhnoKXy8U=",
version = "v0.0.0-20230626064255-5f60f7f5d8e2",
sum = "h1:TN9FcS+r19rKyrsPJDPfcXWkztVHfbpZ9Xkic6kE+v0=",
version = "v0.0.0-20230703085931-3788ab4ee6b3",
)
go_repository(
name = "com_github_pingcap_log",
Expand Down Expand Up @@ -3306,8 +3298,8 @@ def go_deps():
name = "com_github_prometheus_client_golang",
build_file_proto_mode = "disable_global",
importpath = "github.com/prometheus/client_golang",
sum = "h1:8tXpTmJbyH5lydzFPoxSIJ0J46jdh3tylbvM1xCv0LI=",
version = "v1.15.1",
sum = "h1:yk/hx9hDbrGHovbci4BY+pRMfSuuat626eFsHb7tmT8=",
version = "v1.16.0",
)
go_repository(
name = "com_github_prometheus_client_model",
Expand Down Expand Up @@ -3871,8 +3863,8 @@ def go_deps():
name = "com_github_tikv_client_go_v2",
build_file_proto_mode = "disable_global",
importpath = "github.com/tikv/client-go/v2",
sum = "h1:GqsAoNiOFxbCJ8U8Lnts8BvdYd6HDWDsIm/oJY1sIMM=",
version = "v2.0.8-0.20230704071705-c0cf773917d9",
sum = "h1:wRqy8mHs5IocLn4pDvqrwGs4lc3wKhdDXxFyLi8kNbQ=",
version = "v2.0.8-0.20230711075855-e540aa3b9657",
)

go_repository(
Expand Down Expand Up @@ -5680,8 +5672,8 @@ def go_deps():
name = "org_golang_x_text",
build_file_proto_mode = "disable_global",
importpath = "golang.org/x/text",
sum = "h1:UpjohKhiEgNc0CSauXmwYftY1+LlaC75SJwh0SgCX58=",
version = "v0.10.0",
sum = "h1:LAntKIrcmeSKERyiOh0XMV39LXS8IE9UL2yP7+f5ij4=",
version = "v0.11.0",
)
go_repository(
name = "org_golang_x_time",
Expand Down
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,9 @@ br_unit_test_in_verify_ci: tools/bin/gotestsum
br_integration_test: br_bins build_br build_for_br_integration_test
@cd br && tests/run.sh

br_integration_test_debug:
@cd br && tests/run.sh --no-tiflash

br_compatibility_test_prepare:
@cd br && tests/run_compatible.sh prepare

Expand Down
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
<div align="center">

<a href='https://www.pingcap.com/?utm_source=github&utm_medium=tidb'>
<img src="docs/tidb-logo-with-text.png" alt="TiDB, a distributed SQL database" height=100></img>
</a>
<br></br>

[![LICENSE](https://img.shields.io/github/license/pingcap/tidb.svg)](https://github.com/pingcap/tidb/blob/master/LICENSE)
[![Language](https://img.shields.io/badge/Language-Go-blue.svg)](https://golang.org/)
Expand All @@ -9,6 +14,29 @@
[![Coverage Status](https://codecov.io/gh/pingcap/tidb/branch/master/graph/badge.svg)](https://codecov.io/gh/pingcap/tidb)
[![GoDoc](https://img.shields.io/badge/Godoc-reference-blue.svg)](https://godoc.org/github.com/pingcap/tidb)

<div>

[![Official Website](<https://img.shields.io/badge/-Visit%20the%20Official%20Website%20%E2%86%92-rgb(21,204,116)?style=for-the-badge>)](https://www.pingcap.com/?utm_source=github&utm_medium=tidb_readme)
[![Playground](<https://img.shields.io/badge/-Try%20It%20Online%20%E2%86%92-rgb(84,56,255)?style=for-the-badge>)](https://play.tidbcloud.com/?utm_source=github&utm_medium=tidb_readme)

</div>

---

<div>
<a href="https://twitter.com/tidb_developer"><img src="https://img.shields.io/badge/- @TiDB__Developer -424549?style=social&logo=twitter" height=25></a>
&nbsp;
<a href="https://ask.pingcap.com/"><img src="https://img.shields.io/badge/- Forum -red?style=social&logo=discourse" height=25></a>
&nbsp;
<a href="https://slack.tidb.io/invite?team=tidb-community&channel=everyone&ref=pingcap-tidb"><img src="https://img.shields.io/badge/-Slack-red?style=social&logo=slack" height=25></a>
&nbsp;
<a href="https://stackoverflow.com/questions/tagged/tidb"><img src="https://img.shields.io/badge/-Stack Overflow-red?style=social&logo=stackoverflow" height=25></a>
</div>

<br />

</div>

## What is TiDB?

TiDB (/’taɪdiːbi:/, "Ti" stands for Titanium) is an open-source distributed SQL database that supports Hybrid Transactional and Analytical Processing (HTAP) workloads. It is MySQL compatible and features horizontal scalability, strong consistency, and high availability.
Expand Down
12 changes: 6 additions & 6 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ versions.check(minimum_bazel_version = "6.0.0")

http_archive(
name = "io_bazel_rules_go",
sha256 = "bfc5ce70b9d1634ae54f4e7b495657a18a04e0d596785f672d35d5f505ab491a",
sha256 = "278b7ff5a826f3dc10f04feaf0b70d48b68748ccd512d7f98bf442077f043fe3",
urls = [
"http://bazel-cache.pingcap.net:8080/bazelbuild/rules_go/releases/download/v0.40.0/rules_go-v0.40.0.zip",
"http://ats.apps.svc/bazelbuild/rules_go/releases/download/v0.40.0/rules_go-v0.40.0.zip",
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.40.0/rules_go-v0.40.0.zip",
"https://github.com/bazelbuild/rules_go/releases/download/v0.40.0/rules_go-v0.40.0.zip",
"http://bazel-cache.pingcap.net:8080/bazelbuild/rules_go/releases/download/v0.41.0/rules_go-v0.41.0.zip",
"http://ats.apps.svc/bazelbuild/rules_go/releases/download/v0.41.0/rules_go-v0.41.0.zip",
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.41.0/rules_go-v0.41.0.zip",
"https://github.com/bazelbuild/rules_go/releases/download/v0.41.0/rules_go-v0.41.0.zip",
],
)

Expand Down Expand Up @@ -64,7 +64,7 @@ go_download_sdk(
"https://mirrors.aliyun.com/golang/{}",
"https://dl.google.com/go/{}",
],
version = "1.20.5",
version = "1.20.6",
)

go_register_toolchains(
Expand Down
10 changes: 5 additions & 5 deletions WORKSPACE.patchgo
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ versions.check(minimum_bazel_version = "6.0.0")

http_archive(
name = "io_bazel_rules_go",
sha256 = "bfc5ce70b9d1634ae54f4e7b495657a18a04e0d596785f672d35d5f505ab491a",
sha256 = "278b7ff5a826f3dc10f04feaf0b70d48b68748ccd512d7f98bf442077f043fe3",
urls = [
"http://bazel-cache.pingcap.net:8080/bazelbuild/rules_go/releases/download/v0.40.0/rules_go-v0.40.0.zip",
"http://ats.apps.svc/bazelbuild/rules_go/releases/download/v0.40.0/rules_go-v0.40.0.zip",
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.40.0/rules_go-v0.40.0.zip",
"https://github.com/bazelbuild/rules_go/releases/download/v0.40.0/rules_go-v0.40.0.zip",
"http://bazel-cache.pingcap.net:8080/bazelbuild/rules_go/releases/download/v0.41.0/rules_go-v0.41.0.zip",
"http://ats.apps.svc/bazelbuild/rules_go/releases/download/v0.41.0/rules_go-v0.41.0.zip",
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.41.0/rules_go-v0.41.0.zip",
"https://github.com/bazelbuild/rules_go/releases/download/v0.41.0/rules_go-v0.41.0.zip",
],
)

Expand Down
2 changes: 2 additions & 0 deletions br/pkg/gluetidb/glue.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"bytes"
"context"
"strings"
"time"

"github.com/pingcap/errors"
"github.com/pingcap/log"
Expand Down Expand Up @@ -44,6 +45,7 @@ func New() Glue {
config.UpdateGlobal(func(conf *config.Config) {
conf.SkipRegisterToDashboard = true
conf.Log.EnableSlowLog.Store(false)
conf.TiKVClient.CoprReqTimeout = 1800 * time.Second
})
return Glue{}
}
Expand Down
3 changes: 2 additions & 1 deletion br/pkg/lightning/backend/kv/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ go_test(
name = "kv_test",
timeout = "short",
srcs = [
"base_test.go",
"kv2sql_test.go",
"session_internal_test.go",
"session_test.go",
Expand All @@ -56,7 +57,7 @@ go_test(
embed = [":kv"],
flaky = True,
race = "on",
shard_count = 18,
shard_count = 19,
deps = [
"//br/pkg/lightning/backend/encode",
"//br/pkg/lightning/common",
Expand Down
26 changes: 23 additions & 3 deletions br/pkg/lightning/backend/kv/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ import (
"go.uber.org/zap/zapcore"
)

const (
maxLogLength = 512 * 1024
)

// ExtraHandleColumnInfo is the column info of extra handle column.
var ExtraHandleColumnInfo = model.NewExtraHandleColInfo()

Expand Down Expand Up @@ -77,6 +81,7 @@ var kindStr = [...]string{

// MarshalLogArray implements the zapcore.ArrayMarshaler interface
func (row RowArrayMarshaller) MarshalLogArray(encoder zapcore.ArrayEncoder) error {
var totalLength = 0
for _, datum := range row {
kind := datum.Kind()
var str string
Expand All @@ -94,6 +99,14 @@ func (row RowArrayMarshaller) MarshalLogArray(encoder zapcore.ArrayEncoder) erro
return err
}
}
if len(str) > maxLogLength {
str = str[0:1024] + " (truncated)"
}
totalLength += len(str)
if totalLength >= maxLogLength {
encoder.AppendString("The row has been truncated, and the log has exited early.")
return nil
}
if err := encoder.AppendObject(zapcore.ObjectMarshalerFunc(func(enc zapcore.ObjectEncoder) error {
enc.AddString("kind", kindStr[kind])
enc.AddString("val", redact.String(str))
Expand Down Expand Up @@ -307,9 +320,16 @@ func (e *BaseKVEncoder) LogKVConvertFailed(row []types.Datum, j int, colInfo *mo
log.ShortError(err),
)

e.logger.Error("failed to convert kv value", logutil.RedactAny("origVal", original.GetValue()),
zap.Stringer("fieldType", &colInfo.FieldType), zap.String("column", colInfo.Name.O),
zap.Int("columnID", j+1))
if len(original.GetString()) >= maxLogLength {
originalPrefix := original.GetString()[0:1024] + " (truncated)"
e.logger.Error("failed to convert kv value", logutil.RedactAny("origVal", originalPrefix),
zap.Stringer("fieldType", &colInfo.FieldType), zap.String("column", colInfo.Name.O),
zap.Int("columnID", j+1))
} else {
e.logger.Error("failed to convert kv value", logutil.RedactAny("origVal", original.GetValue()),
zap.Stringer("fieldType", &colInfo.FieldType), zap.String("column", colInfo.Name.O),
zap.Int("columnID", j+1))
}
return errors.Annotatef(
err,
"failed to cast value as %s for column `%s` (#%d)", &colInfo.FieldType, colInfo.Name.O, j+1,
Expand Down
75 changes: 75 additions & 0 deletions br/pkg/lightning/backend/kv/base_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
// Copyright 2023 PingCAP, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package kv

import (
"os"
"path/filepath"
"strings"
"testing"

"github.com/pingcap/tidb/br/pkg/lightning/backend/encode"
"github.com/pingcap/tidb/br/pkg/lightning/log"
"github.com/pingcap/tidb/parser/model"
"github.com/pingcap/tidb/parser/mysql"
"github.com/pingcap/tidb/table"
"github.com/pingcap/tidb/table/tables"
"github.com/pingcap/tidb/types"
"github.com/stretchr/testify/require"
)

func TestLogKVConvertFailed(t *testing.T) {
tempPath := filepath.Join(t.TempDir(), "/temp.txt")
logCfg := &log.Config{File: tempPath, FileMaxSize: 1}
err := log.InitLogger(logCfg, "info")
require.NoError(t, err)

modelName := model.NewCIStr("c1")
modelState := model.StatePublic
modelFieldType := *types.NewFieldType(mysql.TypeTiny)
c1 := &model.ColumnInfo{ID: 1, Name: modelName, State: modelState, Offset: 0, FieldType: modelFieldType}
cols := []*model.ColumnInfo{c1}
tblInfo := &model.TableInfo{ID: 1, Columns: cols, PKIsHandle: false, State: model.StatePublic}
var tbl table.Table
tbl, err = tables.TableFromMeta(NewPanickingAllocators(0), tblInfo)
require.NoError(t, err)

var baseKVEncoder *BaseKVEncoder
baseKVEncoder, err = NewBaseKVEncoder(&encode.EncodingConfig{
Table: tbl,
SessionOptions: encode.SessionOptions{
SQLMode: mysql.ModeStrictAllTables,
Timestamp: 1234567890,
},
Logger: log.L(),
})
var newString strings.Builder
for i := 0; i < 100000; i++ {
newString.WriteString("test_test_test_test_")
}
newDatum := types.NewStringDatum(newString.String())
rows := []types.Datum{}
for i := 0; i <= 10; i++ {
rows = append(rows, newDatum)
}
err = baseKVEncoder.LogKVConvertFailed(rows, 6, c1, err)
require.NoError(t, err)

var content []byte
content, err = os.ReadFile(tempPath)
require.NoError(t, err)
require.LessOrEqual(t, 500, len(string(content)))
require.NotContains(t, content, "exceeds maximum file size")
}
Loading

0 comments on commit 37e362d

Please sign in to comment.