Skip to content
This repository has been archived by the owner on Dec 8, 2021. It is now read-only.

glue: add GlueCheckpointDB and remove external TiDB usage #478

Merged
merged 5 commits into from
Nov 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions lightning/backend/importer.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"github.com/pingcap/errors"
kv "github.com/pingcap/kvproto/pkg/import_kvpb"
"github.com/pingcap/parser/model"
"github.com/pingcap/tidb-lightning/lightning/glue"
"github.com/pingcap/tidb/table"
"go.uber.org/zap"
"google.golang.org/grpc"
Expand Down Expand Up @@ -267,6 +268,22 @@ func checkTiDBVersion(tls *common.TLS, requiredVersion semver.Version) error {
return checkVersion("TiDB", requiredVersion, *version)
}

func checkTiDBVersionBySQL(g glue.Glue, requiredVersion semver.Version) error {
versionStr, err := g.GetSQLExecutor().ObtainStringWithLog(
context.Background(),
"SELECT version();",
"check TiDB version",
log.L())
if err != nil {
return errors.Trace(err)
}
version, err := common.ExtractTiDBVersion(versionStr)
if err != nil {
return errors.Trace(err)
}
return checkVersion("TiDB", requiredVersion, *version)
}

func checkPDVersion(tls *common.TLS, pdAddr string, requiredVersion semver.Version) error {
version, err := common.FetchPDVersion(tls, pdAddr)
if err != nil {
Expand Down
6 changes: 5 additions & 1 deletion lightning/backend/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import (
"github.com/pingcap/kvproto/pkg/kvrpcpb"
"github.com/pingcap/kvproto/pkg/metapb"
"github.com/pingcap/parser/model"
"github.com/pingcap/tidb-lightning/lightning/glue"
"github.com/pingcap/tidb/table"
"github.com/pingcap/tidb/util/codec"
"github.com/pingcap/tidb/util/hack"
Expand Down Expand Up @@ -167,6 +168,7 @@ type local struct {
splitCli split.SplitClient
tls *common.TLS
pdAddr string
g glue.Glue

localStoreDir string
regionSplitSize int64
Expand Down Expand Up @@ -248,6 +250,7 @@ func NewLocalBackend(
rangeConcurrency int,
sendKVPairs int,
enableCheckpoint bool,
g glue.Glue,
) (Backend, error) {
pdCli, err := pd.NewClient([]string{pdAddr}, tls.ToPDSecurityOption())
if err != nil {
Expand Down Expand Up @@ -278,6 +281,7 @@ func NewLocalBackend(
splitCli: splitCli,
tls: tls,
pdAddr: pdAddr,
g: g,

localStoreDir: localFile,
regionSplitSize: regionSplitSize,
Expand Down Expand Up @@ -1170,7 +1174,7 @@ func (local *local) CleanupEngine(ctx context.Context, engineUUID uuid.UUID) err
}

func (local *local) CheckRequirements() error {
if err := checkTiDBVersion(local.tls, localMinTiDBVersion); err != nil {
if err := checkTiDBVersionBySQL(local.g, localMinTiDBVersion); err != nil {
return err
}
if err := checkPDVersion(local.tls, local.pdAddr, localMinPDVersion); err != nil {
Expand Down
Loading