Closed
Description
Issue description
Goroutine leak when dial err in go1.8
Example code
package main
import (
"fmt"
"log"
"net/http"
_ "net/http/pprof"
"time"
"github.com/go-sql-driver/mysql"
)
func main() {
go func() {
log.Println(http.ListenAndServe("localhost:6060", nil))
}()
for i := 0; i < 100; i++ {
var driver mysql.MySQLDriver
_, err := driver.Open("USER:PASSWORD_HERE@wrong(127.0.0.1:3306)/DATABASE?charset=utf8&parseTime=True&loc=Local")
fmt.Println(err)
}
time.Sleep(time.Hour * 5)
}
Error log
When you run the code above and access http://127.0.0.1:6060/debug/pprof/goroutine?debug=1;
You can see there are 100 leaked goroutines:
100 @ 0x102df2a 0x103d014 0x103bc7c 0x132e738 0x1059b61
# 0x132e737 github.com/go-sql-driver/mysql.(*mysqlConn).startWatcher.func1+0x287 /Users/zhangyuanjia/Work/src/github.com/go-sql-driver/mysql/connection_go18.go:189
Configuration
Driver version (or git SHA): 8fefef0
Go version: go1.8.1 darwin/amd64
Server version: MySQL 5.6
Server OS: OS X
Metadata
Metadata
Assignees
Labels
No labels