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

*: fix DB connection close and all_mode integration test #403

Merged
merged 7 commits into from
Dec 17, 2019
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
12 changes: 11 additions & 1 deletion pkg/conn/baseconn.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ package conn

import (
"database/sql"
"database/sql/driver"
"fmt"
"strings"

Expand Down Expand Up @@ -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
}
5 changes: 5 additions & 0 deletions tests/all_mode/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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\")"
Expand Down Expand Up @@ -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
Expand Down