Skip to content

Commit d368cea

Browse files
authored
Merge branch 'master' into multiple_host_ip
2 parents 2a444a0 + 893b35c commit d368cea

File tree

17 files changed

+614
-130
lines changed

17 files changed

+614
-130
lines changed

drainer/collector_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ type dummyStore struct {
4646
kv.Storage
4747
}
4848

49-
func (ds dummyStore) CurrentVersion() (kv.Version, error) {
49+
func (ds dummyStore) CurrentVersion(string) (kv.Version, error) {
5050
return kv.NewVersion(2), nil
5151
}
5252

drainer/translator/kafka.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ func deleteRowToRow(ptableinfo, tableInfo *model.TableInfo, raw []byte) (row *ob
168168
columns := tableInfo.Columns
169169

170170
colsTypeMap := util.ToColumnTypeMap(tableInfo.Columns)
171-
columnValues, err := tablecodec.DecodeRow(raw, colsTypeMap, time.Local)
171+
columnValues, err := tablecodec.DecodeRowToDatumMap(raw, colsTypeMap, time.Local)
172172
if err != nil {
173173
return nil, errors.Annotate(err, "DecodeRow failed")
174174
}

drainer/translator/mysql.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ func genMysqlDelete(schema string, table *model.TableInfo, row []byte) (names []
8888
columns := table.Columns
8989
colsTypeMap := util.ToColumnTypeMap(columns)
9090

91-
columnValues, err := tablecodec.DecodeRow(row, colsTypeMap, time.Local)
91+
columnValues, err := tablecodec.DecodeRowToDatumMap(row, colsTypeMap, time.Local)
9292
if err != nil {
9393
return nil, nil, errors.Trace(err)
9494
}
@@ -256,7 +256,7 @@ func formatData(data types.Datum, ft types.FieldType) (types.Datum, error) {
256256
}
257257

258258
switch ft.Tp {
259-
case mysql.TypeDate, mysql.TypeDatetime, mysql.TypeNewDate, mysql.TypeTimestamp, mysql.TypeDuration, mysql.TypeDecimal, mysql.TypeNewDecimal, mysql.TypeJSON:
259+
case mysql.TypeDate, mysql.TypeDatetime, mysql.TypeNewDate, mysql.TypeTimestamp, mysql.TypeDuration, mysql.TypeNewDecimal, mysql.TypeJSON:
260260
data = types.NewDatum(fmt.Sprintf("%v", data.GetValue()))
261261
case mysql.TypeEnum:
262262
data = types.NewDatum(data.GetMysqlEnum().Value)

drainer/translator/pb.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ func genDelete(schema string, table *model.TableInfo, row []byte) (event *pb.Eve
205205
columns := table.Columns
206206
colsTypeMap := util.ToColumnTypeMap(columns)
207207

208-
columnValues, err := tablecodec.DecodeRow(row, colsTypeMap, time.Local)
208+
columnValues, err := tablecodec.DecodeRowToDatumMap(row, colsTypeMap, time.Local)
209209
if err != nil {
210210
return nil, errors.Annotatef(err, "table `%s`.`%s`", schema, table.Name)
211211
}

drainer/translator/translator.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func insertRowToDatums(table *model.TableInfo, row []byte) (pk types.Datum, datu
5454
return types.Datum{}, nil, errors.Trace(err)
5555
}
5656

57-
datums, err = tablecodec.DecodeRow(remain, colsTypeMap, time.Local)
57+
datums, err = tablecodec.DecodeRowToDatumMap(remain, colsTypeMap, time.Local)
5858
if err != nil {
5959
return types.Datum{}, nil, errors.Trace(err)
6060
}

drainer/util.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import (
3030
"github.com/pingcap/tidb-binlog/drainer/checkpoint"
3131
"github.com/pingcap/tidb/kv"
3232
"github.com/pingcap/tidb/meta"
33+
"github.com/pingcap/tidb/store/tikv/oracle"
3334
"go.uber.org/zap"
3435
)
3536

@@ -169,14 +170,11 @@ func loadHistoryDDLJobs(tiStore kv.Storage) ([]*model.Job, error) {
169170
}
170171

171172
func getSnapshotMeta(tiStore kv.Storage) (*meta.Meta, error) {
172-
version, err := tiStore.CurrentVersion()
173-
if err != nil {
174-
return nil, errors.Trace(err)
175-
}
176-
snapshot, err := tiStore.GetSnapshot(version)
173+
version, err := tiStore.CurrentVersion(oracle.GlobalTxnScope)
177174
if err != nil {
178175
return nil, errors.Trace(err)
179176
}
177+
snapshot := tiStore.GetSnapshot(version)
180178
return meta.NewSnapshotMeta(snapshot), nil
181179
}
182180

go.mod

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,39 +2,46 @@ module github.com/pingcap/tidb-binlog
22

33
require (
44
github.com/BurntSushi/toml v0.3.1
5-
github.com/DATA-DOG/go-sqlmock v1.3.0
5+
github.com/DATA-DOG/go-sqlmock v1.5.0
66
github.com/Shopify/sarama v1.24.1
7+
github.com/dgraph-io/ristretto v0.0.2 // indirect
78
github.com/dustin/go-humanize v1.0.0
89
github.com/go-sql-driver/mysql v1.5.0
910
github.com/gogo/protobuf v1.3.1
10-
github.com/golang/mock v1.3.1
11+
github.com/golang/mock v1.4.3
1112
github.com/golang/protobuf v1.3.4
1213
github.com/google/gofuzz v1.0.0
1314
github.com/gorilla/mux v1.7.4
1415
github.com/kami-zh/go-capturer v0.0.0-20171211120116-e492ea43421d
16+
github.com/mattn/go-colorable v0.1.7 // indirect
17+
github.com/mattn/go-runewidth v0.0.9 // indirect
18+
github.com/onsi/ginkgo v1.11.0 // indirect
19+
github.com/onsi/gomega v1.8.1 // indirect
1520
github.com/pingcap/check v0.0.0-20200212061837-5e12011dc712
16-
github.com/pingcap/errors v0.11.5-0.20200917111840-a15ef68f753d
17-
github.com/pingcap/kvproto v0.0.0-20200907074027-32a3a0accf7d
18-
github.com/pingcap/log v0.0.0-20200828042413-fce0951f1463
19-
github.com/pingcap/parser v0.0.0-20201022083903-fbe80b0c40bb
20-
github.com/pingcap/tidb v1.1.0-beta.0.20201027110222-66ac9fc31f17
21-
github.com/pingcap/tidb-tools v4.0.8+incompatible
22-
github.com/pingcap/tipb v0.0.0-20200618092958-4fad48b4c8c3
21+
github.com/pingcap/errors v0.11.5-0.20201126102027-b0a155152ca3
22+
github.com/pingcap/kvproto v0.0.0-20201215060142-f3dafca4c7fd
23+
github.com/pingcap/log v0.0.0-20201112100606-8f1e84a3abc8
24+
github.com/pingcap/parser v0.0.0-20201222091346-02c8ff27d0bc
25+
github.com/pingcap/tidb v1.1.0-beta.0.20201225085011-3e2ff1d16ce5
26+
github.com/pingcap/tidb-tools v4.0.9-0.20201127090955-2707c97b3853+incompatible
27+
github.com/pingcap/tipb v0.0.0-20201209065231-aa39b1b86217
2328
github.com/prometheus/client_golang v1.5.1
2429
github.com/prometheus/client_model v0.2.0
25-
github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a
30+
github.com/rcrowley/go-metrics v0.0.0-20190826022208-cac0b30c2563
2631
github.com/samuel/go-zookeeper v0.0.0-20170815201139-e6b59f6144be
2732
github.com/siddontang/go v0.0.0-20180604090527-bdc77568d726
2833
github.com/soheilhy/cmux v0.1.4
2934
github.com/syndtr/goleveldb v1.0.1-0.20190625010220-02440ea7a285
30-
github.com/tikv/pd v1.1.0-beta.0.20200921100508-9ee41c4144f3
31-
github.com/unrolled/render v0.0.0-20180914162206-b9786414de4d
32-
go.etcd.io/etcd v0.5.0-alpha.5.0.20191023171146-3cf2f69b5738
35+
github.com/tikv/pd v1.1.0-beta.0.20201125070607-d4b90eee0c70
36+
github.com/unrolled/render v1.0.1
37+
go.etcd.io/bbolt v1.3.5 // indirect
38+
go.etcd.io/etcd v0.5.0-alpha.5.0.20200824191128-ae9734ed278b
3339
go.uber.org/zap v1.16.0
34-
golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc
35-
golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208
40+
golang.org/x/net v0.0.0-20200904194848-62affa334b73
41+
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9
3642
golang.org/x/sys v0.0.0-20200819171115-d785dc25833f
37-
google.golang.org/grpc v1.26.0
43+
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
44+
google.golang.org/grpc v1.27.1
3845
)
3946

4047
go 1.13

0 commit comments

Comments
 (0)