Skip to content
This repository has been archived by the owner on Nov 24, 2023. It is now read-only.

Commit

Permalink
add detect server version
Browse files Browse the repository at this point in the history
  • Loading branch information
lichunzhu authored and ti-chi-bot committed May 13, 2021
1 parent 6a8ba8b commit 8abbc49
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
2 changes: 2 additions & 0 deletions syncer/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -2468,6 +2468,8 @@ func (s *Syncer) createDBs(ctx context.Context) error {
return err
}
s.ddlDBConn = ddlDBConns[0]
printServerVersion(s.tctx, s.fromDB.BaseDB, "upstream")
printServerVersion(s.tctx, s.toDB, "downstream")

return nil
}
Expand Down
17 changes: 17 additions & 0 deletions syncer/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,16 @@ import (
"os"
"strconv"

dcontext "github.com/pingcap/dumpling/v4/context"
"github.com/pingcap/dumpling/v4/export"
dlog "github.com/pingcap/dumpling/v4/log"
"github.com/pingcap/parser/ast"
"github.com/pingcap/tidb-tools/pkg/filter"
"go.uber.org/zap"

"github.com/pingcap/dm/dm/config"
"github.com/pingcap/dm/pkg/conn"
tcontext "github.com/pingcap/dm/pkg/context"
"github.com/pingcap/dm/pkg/terror"
)

Expand Down Expand Up @@ -126,3 +132,14 @@ func recordSourceTbls(sourceTbls map[string]map[string]struct{}, stmt ast.StmtNo
sourceTbls[schema][name] = struct{}{}
}
}

func printServerVersion(tctx *tcontext.Context, db *conn.BaseDB, scope string) {
logger := dlog.NewAppLogger(tctx.Logger.With(zap.String("scope", scope)))
versionInfo, err := export.SelectVersion(db.DB)
if err != nil {
logger.Warn("fail to get version info", zap.Error(err))
return
}
dctx := dcontext.NewContext(tctx.Ctx, logger)
export.ParseServerInfo(dctx, versionInfo)
}

0 comments on commit 8abbc49

Please sign in to comment.