Skip to content

Commit

Permalink
*: Remove tidb-binlog related code (#56183)
Browse files Browse the repository at this point in the history
ref #55949
  • Loading branch information
Benjamin2037 committed Sep 20, 2024
1 parent 6d3439a commit 5ead7e9
Show file tree
Hide file tree
Showing 16 changed files with 9 additions and 115 deletions.
12 changes: 6 additions & 6 deletions DEPS.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -5893,13 +5893,13 @@ def go_deps():
name = "com_github_pingcap_tipb",
build_file_proto_mode = "disable_global",
importpath = "github.com/pingcap/tipb",
sha256 = "598bb728ddaf83863e7c79c8790cd2ae907c7ae762b13bfcf4164da5b9e2e4dc",
strip_prefix = "github.com/pingcap/tipb@v0.0.0-20240823074000-a40c2347786e",
sha256 = "119f73cede33a7d3712a9fedeb80f806228ecf1ec5258112b2b62af88731a304",
strip_prefix = "github.com/pingcap/tipb@v0.0.0-20240919023442-cf70966bef25",
urls = [
"http://bazel-cache.pingcap.net:8080/gomod/github.com/pingcap/tipb/com_github_pingcap_tipb-v0.0.0-20240823074000-a40c2347786e.zip",
"http://ats.apps.svc/gomod/github.com/pingcap/tipb/com_github_pingcap_tipb-v0.0.0-20240823074000-a40c2347786e.zip",
"https://cache.hawkingrei.com/gomod/github.com/pingcap/tipb/com_github_pingcap_tipb-v0.0.0-20240823074000-a40c2347786e.zip",
"https://storage.googleapis.com/pingcapmirror/gomod/github.com/pingcap/tipb/com_github_pingcap_tipb-v0.0.0-20240823074000-a40c2347786e.zip",
"http://bazel-cache.pingcap.net:8080/gomod/github.com/pingcap/tipb/com_github_pingcap_tipb-v0.0.0-20240919023442-cf70966bef25.zip",
"http://ats.apps.svc/gomod/github.com/pingcap/tipb/com_github_pingcap_tipb-v0.0.0-20240919023442-cf70966bef25.zip",
"https://cache.hawkingrei.com/gomod/github.com/pingcap/tipb/com_github_pingcap_tipb-v0.0.0-20240919023442-cf70966bef25.zip",
"https://storage.googleapis.com/pingcapmirror/gomod/github.com/pingcap/tipb/com_github_pingcap_tipb-v0.0.0-20240919023442-cf70966bef25.zip",
],
)
go_repository(
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ require (
github.com/pingcap/log v1.1.1-0.20240314023424-862ccc32f18d
github.com/pingcap/sysutil v1.0.1-0.20240311050922-ae81ee01f3a5
github.com/pingcap/tidb/pkg/parser v0.0.0-20211011031125-9b13dc409c5e
github.com/pingcap/tipb v0.0.0-20240823074000-a40c2347786e
github.com/pingcap/tipb v0.0.0-20240919023442-cf70966bef25
github.com/prometheus/client_golang v1.20.4
github.com/prometheus/client_model v0.6.1
github.com/prometheus/common v0.57.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -676,8 +676,8 @@ github.com/pingcap/log v1.1.1-0.20240314023424-862ccc32f18d h1:y3EueKVfVykdpTyfU
github.com/pingcap/log v1.1.1-0.20240314023424-862ccc32f18d/go.mod h1:ORfBOFp1eteu2odzsyaxI+b8TzJwgjwyQcGhI+9SfEA=
github.com/pingcap/sysutil v1.0.1-0.20240311050922-ae81ee01f3a5 h1:T4pXRhBflzDeAhmOQHNPRRogMYxP13V7BkYw3ZsoSfE=
github.com/pingcap/sysutil v1.0.1-0.20240311050922-ae81ee01f3a5/go.mod h1:rlimy0GcTvjiJqvD5mXTRr8O2eNZPBrcUgiWVYp9530=
github.com/pingcap/tipb v0.0.0-20240823074000-a40c2347786e h1:chR6iRwU9MUivOYNH+26UqrO8Y7t3ZltX+Jukv+f+iM=
github.com/pingcap/tipb v0.0.0-20240823074000-a40c2347786e/go.mod h1:A7mrd7WHBl1o63LE2bIBGEJMTNWXqhgmYiOvMLxozfs=
github.com/pingcap/tipb v0.0.0-20240919023442-cf70966bef25 h1:qH261jtqDvqWhhsnle+eURWV+PmFdqEGP/aHDqPFJAs=
github.com/pingcap/tipb v0.0.0-20240919023442-cf70966bef25/go.mod h1:A7mrd7WHBl1o63LE2bIBGEJMTNWXqhgmYiOvMLxozfs=
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ=
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU=
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
Expand Down
3 changes: 0 additions & 3 deletions pkg/parser/ast/misc.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,6 @@ const (
ReadUncommitted = "READ-UNCOMMITTED"
Serializable = "SERIALIZABLE"
RepeatableRead = "REPEATABLE-READ"

PumpType = "PUMP"
DrainerType = "DRAINER"
)

// Transaction mode constants.
Expand Down
1 change: 0 additions & 1 deletion pkg/session/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ go_library(
"@com_github_pingcap_failpoint//:failpoint",
"@com_github_pingcap_kvproto//pkg/kvrpcpb",
"@com_github_pingcap_log//:log",
"@com_github_pingcap_tipb//go-binlog",
"@com_github_stretchr_testify//require",
"@com_github_tikv_client_go_v2//error",
"@com_github_tikv_client_go_v2//oracle",
Expand Down
35 changes: 0 additions & 35 deletions pkg/session/txn.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import (
"github.com/pingcap/tidb/pkg/util/logutil"
"github.com/pingcap/tidb/pkg/util/sli"
"github.com/pingcap/tidb/pkg/util/syncutil"
"github.com/pingcap/tipb/go-binlog"
"github.com/tikv/client-go/v2/oracle"
"github.com/tikv/client-go/v2/tikv"
"go.uber.org/zap"
Expand All @@ -56,7 +55,6 @@ type LazyTxn struct {

initCnt int
stagingHandle kv.StagingHandle
mutations map[int64]*binlog.TableMutation
writeSLI sli.TxnWriteThroughputSLI

enterFairLockingOnValid bool
Expand Down Expand Up @@ -85,7 +83,6 @@ func (txn *LazyTxn) CacheTableInfo(id int64, info *model.TableInfo) {
}

func (txn *LazyTxn) init() {
txn.mutations = make(map[int64]*binlog.TableMutation)
txn.mu.Lock()
defer txn.mu.Unlock()
txn.mu.TxnInfo = txninfo.TxnInfo{}
Expand Down Expand Up @@ -257,9 +254,6 @@ func (txn *LazyTxn) GoString() string {
} else if txn.Valid() {
s.WriteString("state=valid")
fmt.Fprintf(&s, ", txnStartTS=%d", txn.Transaction.StartTS())
if len(txn.mutations) > 0 {
fmt.Fprintf(&s, ", len(mutations)=%d, %#v", len(txn.mutations), txn.mutations)
}
} else {
s.WriteString("state=invalid")
}
Expand Down Expand Up @@ -408,14 +402,6 @@ func ResetMockAutoRandIDRetryCount(failTimes int64) {
// Commit overrides the Transaction interface.
func (txn *LazyTxn) Commit(ctx context.Context) error {
defer txn.reset()
if len(txn.mutations) != 0 || txn.countHint() != 0 {
logutil.BgLogger().Error("the code should never run here",
zap.String("TxnState", txn.GoString()),
zap.Int("staging handler", int(txn.stagingHandle)),
zap.Int("mutations", txn.countHint()),
zap.Stack("something must be wrong"))
return errors.Trace(kv.ErrInvalidTxn)
}

txn.mu.Lock()
txn.updateState(txninfo.TxnCommitting)
Expand Down Expand Up @@ -576,9 +562,6 @@ func (txn *LazyTxn) reset() {
func (txn *LazyTxn) cleanup() {
txn.cleanupStmtBuf()
txn.initStmtBuf()
for key := range txn.mutations {
delete(txn.mutations, key)
}
}

// KeysNeedToLock returns the keys need to be locked.
Expand Down Expand Up @@ -667,15 +650,6 @@ func KeyNeedToLock(k, v []byte, flags kv.KeyFlags) bool {
return tablecodec.IndexKVIsUnique(v)
}

func mergeToMutation(m1, m2 *binlog.TableMutation) {
m1.InsertedRows = append(m1.InsertedRows, m2.InsertedRows...)
m1.UpdatedRows = append(m1.UpdatedRows, m2.UpdatedRows...)
m1.DeletedIds = append(m1.DeletedIds, m2.DeletedIds...)
m1.DeletedPks = append(m1.DeletedPks, m2.DeletedPks...)
m1.DeletedRows = append(m1.DeletedRows, m2.DeletedRows...)
m1.Sequence = append(m1.Sequence, m2.Sequence...)
}

type txnFailFuture struct{}

func (txnFailFuture) Wait() (uint64, error) {
Expand Down Expand Up @@ -748,12 +722,3 @@ func (s *session) StmtRollback(ctx context.Context, isForPessimisticRetry bool)
}
s.txn.cleanup()
}

// StmtGetMutation implements the sessionctx.Context interface.
func (s *session) StmtGetMutation(tableID int64) *binlog.TableMutation {
st := &s.txn
if _, ok := st.mutations[tableID]; !ok {
st.mutations[tableID] = &binlog.TableMutation{TableId: tableID}
}
return st.mutations[tableID]
}
1 change: 0 additions & 1 deletion pkg/sessionctx/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ go_library(
"//pkg/util/sqlexec",
"//pkg/util/topsql/stmtstats",
"@com_github_pingcap_errors//:errors",
"@com_github_pingcap_tipb//go-binlog",
"@com_github_tikv_client_go_v2//oracle",
],
)
Expand Down
3 changes: 0 additions & 3 deletions pkg/sessionctx/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ import (
"github.com/pingcap/tidb/pkg/util/sli"
"github.com/pingcap/tidb/pkg/util/sqlexec"
"github.com/pingcap/tidb/pkg/util/topsql/stmtstats"
"github.com/pingcap/tipb/go-binlog"
"github.com/tikv/client-go/v2/oracle"
)

Expand Down Expand Up @@ -172,8 +171,6 @@ type Context interface {
// before you start another batch, otherwise, the previous changes might be committed
// unexpectedly.
StmtRollback(ctx context.Context, isForPessimisticRetry bool)
// StmtGetMutation gets the binlog mutation for current statement.
StmtGetMutation(int64) *binlog.TableMutation
// IsDDLOwner checks whether this session is DDL owner.
IsDDLOwner() bool
// PrepareTSFuture uses to prepare timestamp by future.
Expand Down
1 change: 0 additions & 1 deletion pkg/table/tblsession/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ go_test(
"//pkg/table",
"//pkg/table/tables",
"//pkg/util/mock",
"@com_github_pingcap_tipb//go-binlog",
"@com_github_stretchr_testify//require",
],
)
2 changes: 0 additions & 2 deletions pkg/table/tblsession/table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
_ "github.com/pingcap/tidb/pkg/table/tables"
"github.com/pingcap/tidb/pkg/table/tblsession"
"github.com/pingcap/tidb/pkg/util/mock"
"github.com/pingcap/tipb/go-binlog"
"github.com/stretchr/testify/require"
)

Expand All @@ -39,7 +38,6 @@ func (m *mockTemporaryData) GetTableSize(tableID int64) int64 {

func TestSessionMutateContextFields(t *testing.T) {
sctx := mock.NewContext()
sctx.Mutations = make(map[int64]*binlog.TableMutation)
ctx := tblsession.NewMutateContext(sctx)
// expression
require.True(t, sctx.GetExprCtx() == ctx.GetExprCtx())
Expand Down
2 changes: 0 additions & 2 deletions pkg/testkit/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,12 @@ go_library(
"@com_github_gorilla_mux//:mux",
"@com_github_pingcap_errors//:errors",
"@com_github_pingcap_failpoint//:failpoint",
"@com_github_pingcap_tipb//go-binlog",
"@com_github_prometheus_client_golang//prometheus/promhttp",
"@com_github_stretchr_testify//assert",
"@com_github_stretchr_testify//require",
"@com_github_tikv_client_go_v2//tikv",
"@com_github_tikv_client_go_v2//tikvrpc",
"@io_opencensus_go//stats/view",
"@org_golang_google_grpc//:grpc",
"@org_uber_go_atomic//:atomic",
"@org_uber_go_zap//:zap",
],
Expand Down
15 changes: 0 additions & 15 deletions pkg/testkit/testkit.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,12 @@ import (
"github.com/pingcap/tidb/pkg/util/intest"
"github.com/pingcap/tidb/pkg/util/metricsutil"
"github.com/pingcap/tidb/pkg/util/sqlexec"
"github.com/pingcap/tipb/go-binlog"
"github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/tikv/client-go/v2/tikv"
"github.com/tikv/client-go/v2/tikvrpc"
"go.uber.org/atomic"
"google.golang.org/grpc"
)

var testKitIDGenerator atomic.Uint64
Expand Down Expand Up @@ -683,19 +681,6 @@ func (c *RegionProperityClient) SendRequest(ctx context.Context, addr string, re
return c.Client.SendRequest(ctx, addr, req, timeout)
}

// MockPumpClient is a mock pump client.
type MockPumpClient struct{}

// WriteBinlog is a mock method.
func (m MockPumpClient) WriteBinlog(ctx context.Context, in *binlog.WriteBinlogReq, opts ...grpc.CallOption) (*binlog.WriteBinlogResp, error) {
return &binlog.WriteBinlogResp{}, nil
}

// PullBinlogs is a mock method.
func (m MockPumpClient) PullBinlogs(ctx context.Context, in *binlog.PullBinlogReq, opts ...grpc.CallOption) (binlog.Pump_PullBinlogsClient, error) {
return nil, nil
}

var _ sqlexec.RecordSet = &rowsRecordSet{}

type rowsRecordSet struct {
Expand Down
1 change: 0 additions & 1 deletion pkg/util/mock/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ go_library(
"@com_github_pingcap_errors//:errors",
"@com_github_pingcap_kvproto//pkg/deadlock",
"@com_github_pingcap_kvproto//pkg/kvrpcpb",
"@com_github_pingcap_tipb//go-binlog",
"@com_github_prometheus_client_golang//prometheus",
"@com_github_stretchr_testify//assert",
"@com_github_tikv_client_go_v2//oracle",
Expand Down
15 changes: 0 additions & 15 deletions pkg/util/mock/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ import (
"github.com/pingcap/tidb/pkg/util/sli"
"github.com/pingcap/tidb/pkg/util/sqlexec"
"github.com/pingcap/tidb/pkg/util/topsql/stmtstats"
"github.com/pingcap/tipb/go-binlog"
"github.com/tikv/client-go/v2/oracle"
"github.com/tikv/client-go/v2/tikv"
)
Expand All @@ -70,7 +69,6 @@ type Context struct {
sm util.SessionManager
is infoschema.MetaOnlyInfoSchema
values map[fmt.Stringer]any
Mutations map[int64]*binlog.TableMutation
sessionVars *variable.SessionVars
tblctx *tblsession.MutateContext
cancel context.CancelFunc
Expand Down Expand Up @@ -484,19 +482,6 @@ func (*Context) StmtCommit(context.Context) {}
// StmtRollback implements the sessionctx.Context interface.
func (*Context) StmtRollback(context.Context, bool) {}

// StmtGetMutation implements the sessionctx.Context interface.
func (c *Context) StmtGetMutation(tblID int64) *binlog.TableMutation {
if c.Mutations == nil {
return nil
}
m, ok := c.Mutations[tblID]
if !ok {
m = &binlog.TableMutation{}
c.Mutations[tblID] = m
}
return m
}

// AddTableLock implements the sessionctx.Context interface.
func (*Context) AddTableLock(_ []model.TableLockTpInfo) {
}
Expand Down
2 changes: 0 additions & 2 deletions tests/realtikvtest/brietest/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ go_test(
"//pkg/executor",
"//pkg/parser/mysql",
"//pkg/session",
"//pkg/store/mockstore/mockcopr",
"//pkg/testkit",
"//pkg/testkit/testsetup",
"//tests/realtikvtest",
Expand All @@ -28,7 +27,6 @@ go_test(
"@com_github_pingcap_kvproto//pkg/import_sstpb",
"@com_github_pingcap_kvproto//pkg/kvrpcpb",
"@com_github_pingcap_log//:log",
"@com_github_pingcap_tipb//go-binlog",
"@com_github_stretchr_testify//require",
"@com_github_tikv_client_go_v2//oracle",
"@com_github_tikv_pd_client//:client",
Expand Down
25 changes: 0 additions & 25 deletions tests/realtikvtest/brietest/binlog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,39 +15,14 @@
package brietest

import (
"context"
"testing"

"github.com/pingcap/tidb/pkg/parser/mysql"
"github.com/pingcap/tidb/pkg/store/mockstore/mockcopr"
"github.com/pingcap/tidb/pkg/testkit"
"github.com/pingcap/tidb/tests/realtikvtest"
"github.com/pingcap/tipb/go-binlog"
"github.com/stretchr/testify/require"
"google.golang.org/grpc"
)

type mockBinlogPump struct {
}

var _ binlog.PumpClient = &mockBinlogPump{}

func (p *mockBinlogPump) WriteBinlog(_ context.Context, _ *binlog.WriteBinlogReq, _ ...grpc.CallOption) (*binlog.WriteBinlogResp, error) {
return &binlog.WriteBinlogResp{}, nil
}

func (p *mockBinlogPump) PullBinlogs(_ context.Context, _ *binlog.PullBinlogReq, _ ...grpc.CallOption) (binlog.Pump_PullBinlogsClient, error) {
return mockPumpPullBinlogsClient{mockcopr.MockGRPCClientStream()}, nil
}

type mockPumpPullBinlogsClient struct {
grpc.ClientStream
}

func (m mockPumpPullBinlogsClient) Recv() (*binlog.PullBinlogResp, error) {
return nil, nil
}

func TestForCoverage(t *testing.T) {
// Just for test coverage.
store := realtikvtest.CreateMockStoreAndSetup(t)
Expand Down

0 comments on commit 5ead7e9

Please sign in to comment.