Skip to content

Commit

Permalink
kafka.go: Refine log (pingcap#778)
Browse files Browse the repository at this point in the history
  • Loading branch information
july2993 authored and sre-bot committed Oct 29, 2019
1 parent 71645cd commit cd006ab
Show file tree
Hide file tree
Showing 11 changed files with 323 additions and 183 deletions.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ TEST_DIR := /tmp/tidb_binlog_test
GO := GO111MODULE=on go
GOBUILD := CGO_ENABLED=0 $(GO) build $(BUILD_FLAG)
GOTEST := CGO_ENABLED=1 $(GO) test -p 3
GOVERSION := "`go version`"

ARCH := "`uname -s`"
LINUX := "Linux"
Expand Down Expand Up @@ -77,6 +78,7 @@ integration_test: build
tests/run.sh

fmt:
@echo "${GOVERSION}"
@echo "gofmt (simplify)"
@gofmt -s -l -w $(FILES) 2>&1 | $(FAIL_ON_STDOUT)

Expand Down
2 changes: 1 addition & 1 deletion drainer/sync/kafka.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ func (p *KafkaSyncer) run() {
defer wg.Done()

for err := range p.producer.Errors() {
panic(err)
log.Fatal("fail to produce message to kafka, please check the state of kafka server", zap.Error(err))
}
}()

Expand Down
2 changes: 1 addition & 1 deletion drainer/translator/flash.go
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ func analyzeColumnDef(colDef *ast.ColumnDef, pkColumn string) (string, error) {
cName := colDef.Name.Name.L

tp := colDef.Tp
var typeStr = ""
var typeStr string
var typeStrFormat = "%s"
unsigned := mysql.HasUnsignedFlag(tp.Flag)
nullable := cName != pkColumn && isNullable(colDef)
Expand Down
22 changes: 11 additions & 11 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,26 @@ require (
github.com/BurntSushi/toml v0.3.1
github.com/DATA-DOG/go-sqlmock v1.3.0
github.com/Shopify/sarama v1.23.1
github.com/beorn7/perks v1.0.0 // indirect
github.com/coreos/etcd v3.3.13+incompatible
github.com/dustin/go-humanize v1.0.0
github.com/go-sql-driver/mysql v1.4.1
github.com/gogo/protobuf v1.2.0
github.com/golang/mock v1.2.0
github.com/golang/protobuf v1.3.1
github.com/golang/protobuf v1.3.2
github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf
github.com/gorilla/mux v1.6.2
github.com/kami-zh/go-capturer v0.0.0-20171211120116-e492ea43421d
github.com/pierrec/lz4 v2.0.5+incompatible // indirect
github.com/pingcap/check v0.0.0-20190102082844-67f458068fc8
github.com/pingcap/errors v0.11.4
github.com/pingcap/kvproto v0.0.0-20190703131923-d9830856b531
github.com/pingcap/log v0.0.0-20190307075452-bd41d9273596
github.com/pingcap/parser v0.0.0-20190910041007-2a177b291004
github.com/pingcap/pd v0.0.0-20190711034019-ee98bf9063e9
github.com/pingcap/tidb v0.0.0-20190917133016-45d7da02f66e
github.com/pingcap/kvproto v0.0.0-20190910074005-0e61b6f435c1
github.com/pingcap/log v0.0.0-20191012051959-b742a5d432e9
github.com/pingcap/parser v0.0.0-20191021083151-7c64f78a5100
github.com/pingcap/pd v1.1.0-beta.0.20190923032047-5c648dc365e0
github.com/pingcap/tidb v1.1.0-beta.0.20191023070859-58fc7d44f73b
github.com/pingcap/tidb-tools v2.1.12+incompatible
github.com/pingcap/tipb v0.0.0-20190428032612-535e1abaa330
github.com/pingcap/tipb v0.0.0-20191015023537-709b39e7f8bb
github.com/prometheus/client_golang v0.9.0
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910
github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a
Expand All @@ -35,11 +36,10 @@ require (
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5 // indirect
github.com/unrolled/render v0.0.0-20180914162206-b9786414de4d
github.com/zanmato1984/clickhouse v1.3.4-0.20181106115746-3e9a6b9beb12
go.uber.org/zap v1.9.1
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3
go.uber.org/zap v1.10.0
golang.org/x/net v0.0.0-20190909003024-a7b16738d86b
golang.org/x/sync v0.0.0-20190423024810-112230192c58
golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4 // indirect
golang.org/x/sys v0.0.0-20190910064555-bbd175535a8b
google.golang.org/grpc v1.23.0
gopkg.in/jcmturner/goidentity.v3 v3.0.0 // indirect
)
Expand Down
88 changes: 54 additions & 34 deletions go.sum

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions pkg/util/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ func InitLogger(level string, file string) error {
cfg := &log.Config{
Level: level,
File: log.FileLogConfig{
Filename: file,
LogRotate: true,
Filename: file,
// default rotate by size 300M in pingcap/log never delete old files
// MaxSize:
// MaxDays:
Expand Down
10 changes: 5 additions & 5 deletions pump/storage/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ func (h *Helper) GetMvccByEncodedKey(encodedKey kv.Key) (*kvrpcpb.MvccGetByKeyRe
return nil, errors.Trace(err)
}

tikvReq := &tikvrpc.Request{
Type: tikvrpc.CmdMvccGetByKey,
MvccGetByKey: &kvrpcpb.MvccGetByKeyRequest{
tikvReq := tikvrpc.NewRequest(
tikvrpc.CmdMvccGetByKey,
&kvrpcpb.MvccGetByKeyRequest{
Key: encodedKey,
},
}
)
kvResp, err := h.Store.SendReq(tikv.NewBackoffer(context.Background(), 500), tikvReq, keyLocation.Region, time.Minute)
if err != nil {
log.Info("get MVCC by encoded key failed",
Expand All @@ -59,5 +59,5 @@ func (h *Helper) GetMvccByEncodedKey(encodedKey kv.Key) (*kvrpcpb.MvccGetByKeyRe
zap.Error(err))
return nil, errors.Trace(err)
}
return kvResp.MvccGetByKey, nil
return kvResp.Resp.(*kvrpcpb.MvccGetByKeyResponse), nil
}
2 changes: 1 addition & 1 deletion pump/storage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ func (a *Append) resolve(startTS int64) bool {

tikvQueryCount.Add(1.0)
primaryKey := pbinlog.GetPrewriteKey()
status, err := a.tiLockResolver.GetTxnStatus(uint64(pbinlog.StartTs), primaryKey)
status, err := a.tiLockResolver.GetTxnStatus(uint64(pbinlog.StartTs), uint64(pbinlog.StartTs), primaryKey)
if err != nil {
log.Error("GetTxnStatus failed", zap.Error(err))
return false
Expand Down
4 changes: 3 additions & 1 deletion reparo/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ func NewConfig() *Config {
}

func (c *Config) String() string {
cfgBytes, err := json.Marshal(c)
// reparo/config.go:94:31: SA1026: trying to marshal chan or func value, field *github.com/pingcap/tidb-binlog/reparo.Config.FlagSet.Usage (staticcheck)
// but we omit the field `*flag.FlagSet`, it should be ok.
cfgBytes, err := json.Marshal(c) //nolint:staticcheck
if err != nil {
log.Error("marshal config failed", zap.Error(err))
}
Expand Down
17 changes: 2 additions & 15 deletions tools/check/go.mod
Original file line number Diff line number Diff line change
@@ -1,21 +1,8 @@
module github.com/pingcap/tidb-binlog/_tools

require (
github.com/go-critic/go-critic v0.0.0-20181204210945-ee9bf5809ead // indirect
github.com/golangci/golangci-lint v1.16.1-0.20190425135923-692dacb773b7
github.com/mattn/go-colorable v0.1.1 // indirect
github.com/mattn/go-isatty v0.0.7 // indirect
github.com/mattn/go-runewidth v0.0.4 // indirect
github.com/mgechev/dots v0.0.0-20181228164730-18fa4c4b71cc // indirect
github.com/mgechev/revive v0.0.0-20190422175802-e8c1baf8ac0e
github.com/olekukonko/tablewriter v0.0.1 // indirect
github.com/pkg/errors v0.8.1 // indirect
golang.org/x/crypto v0.0.0-20190426145343-a29dc8fdc734 // indirect
golang.org/x/net v0.0.0-20190424112056-4829fb13d2c6 // indirect
golang.org/x/sys v0.0.0-20190426135247-a129542de9ae // indirect
golang.org/x/text v0.3.2 // indirect
golang.org/x/tools v0.0.0-20190425222832-ad9eeb80039a // indirect
sourcegraph.com/sourcegraph/go-diff v0.5.1-0.20190210232911-dee78e514455 // indirect
github.com/golangci/golangci-lint v1.21.0 // indirect
github.com/mgechev/revive v0.0.0-20191017201419-88015ccf8e97 // indirect
)

go 1.13
Loading

0 comments on commit cd006ab

Please sign in to comment.