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

Commit

Permalink
cherry pick #1477 to release-2.0 (#1481)
Browse files Browse the repository at this point in the history
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>

Co-authored-by: lance6716 <lance6716@gmail.com>
  • Loading branch information
ti-srebot and lance6716 authored Mar 5, 2021
1 parent 295bca0 commit b4f1aec
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pkg/conn/basedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"github.com/pingcap/dm/dm/config"
"github.com/pingcap/dm/pkg/retry"
"github.com/pingcap/dm/pkg/terror"
"github.com/pingcap/dm/pkg/utils"

"github.com/go-sql-driver/mysql"
toolutils "github.com/pingcap/tidb-tools/pkg/utils"
Expand Down Expand Up @@ -112,7 +113,9 @@ func (d *DefaultDBProviderImpl) Apply(config config.DBConfig) (*BaseDB, error) {
mockDB.ExpectClose()
})

err = db.Ping()
ctx, cancel := context.WithTimeout(context.Background(), utils.DefaultDBTimeout)
defer cancel()
err = db.PingContext(ctx)
failpoint.Inject("failDBPing", func(_ failpoint.Value) {
err = errors.New("injected error")
})
Expand Down

0 comments on commit b4f1aec

Please sign in to comment.