diff --git a/pkg/conn/baseconn.go b/pkg/conn/baseconn.go index 86757872be..ee4b0d8276 100644 --- a/pkg/conn/baseconn.go +++ b/pkg/conn/baseconn.go @@ -15,6 +15,7 @@ package conn import ( "database/sql" + "database/sql/driver" "fmt" "strings" @@ -207,5 +208,14 @@ func (conn *BaseConn) close() error { if conn == nil || conn.DBConn == nil { return nil } - return terror.ErrDBUnExpect.Delegate(conn.DBConn.Close(), "close") + + err := conn.DBConn.Raw(func(dc interface{}) error { + // return an `ErrBadConn` to ensure close the connection, but do not put it back to the pool. + // if we choose to use `Close`, it will always put the connection back to the pool. + return driver.ErrBadConn + }) + if err != driver.ErrBadConn { + return terror.ErrDBUnExpect.Delegate(err, "close") + } + return nil } diff --git a/tests/all_mode/run.sh b/tests/all_mode/run.sh index de61b75765..db36a74e32 100755 --- a/tests/all_mode/run.sh +++ b/tests/all_mode/run.sh @@ -5,6 +5,7 @@ set -eu cur=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) source $cur/../_utils/test_prepare WORK_DIR=$TEST_DIR/$TEST_NAME +API_VERSION="v1alpha1" function run() { export GO_FAILPOINTS="github.com/pingcap/dm/dm/worker/TaskCheckInterval=return(\"500ms\")" @@ -34,6 +35,10 @@ function run() { run_dm_worker $WORK_DIR/worker1 $WORKER1_PORT $cur/conf/dm-worker1.toml run_dm_worker $WORK_DIR/worker2 $WORKER2_PORT $cur/conf/dm-worker2.toml + # wait for task running + check_http_alive 127.0.0.1:$MASTER_PORT/apis/${API_VERSION}/status/test '"name":"test","stage":"Running"' 10 + sleep 2 # still wait for subtask running on other dm-workers + # kill tidb pkill -hup tidb-server 2>/dev/null || true wait_process_exit tidb-server