Skip to content

Commit

Permalink
Set max idle connections when connect TiDB; Fix log print when delete. (
Browse files Browse the repository at this point in the history
  • Loading branch information
cxt90730 authored and dahefanteng committed Dec 21, 2018
1 parent 7bf351c commit 41bdc2b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 4 additions & 0 deletions meta/client/tidbclient/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
"os"
)

const MAX_OPEN_CONNS = 1024

type TidbClient struct {
Client *sql.DB
}
Expand All @@ -17,6 +19,8 @@ func NewTidbClient() *TidbClient {
if err != nil {
os.Exit(1)
}
conn.SetMaxIdleConns(0)
conn.SetMaxOpenConns(MAX_OPEN_CONNS)
cli.Client = conn
return cli
}
6 changes: 3 additions & 3 deletions tools/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ func deleteFromCeph(index int) {
Remove(garbage.Pool, garbage.ObjectId)
if err != nil {
if strings.Contains(err.Error(), "ret=-2") {
helper.Logger.Println(5, "failed delete", garbage.BucketName, ":", garbage.ObjectName, ":",
garbage.Location, ":", garbage.Pool, ":", garbage.ObjectId, " error:", err)
goto release
}
helper.Logger.Println(5, "failed delete", garbage.BucketName, ":", garbage.ObjectName, ":",
garbage.Location, ":", garbage.Pool, ":", garbage.ObjectId, " error:", err)
} else {
helper.Logger.Println(5, "success delete", garbage.BucketName, ":", garbage.ObjectName, ":",
garbage.Location, ":", garbage.Pool, ":", garbage.ObjectId)
Expand All @@ -61,9 +61,9 @@ func deleteFromCeph(index int) {
Remove(garbage.Pool, p.ObjectId)
if err != nil {
if strings.Contains(err.Error(), "ret=-2") {
helper.Logger.Println(5, "failed delete part", garbage.Location, ":", garbage.Pool, ":", p.ObjectId, " error:", err)
goto release
}
helper.Logger.Println(5, "failed delete part", garbage.Location, ":", garbage.Pool, ":", p.ObjectId, " error:", err)
} else {
helper.Logger.Println(5, "success delete part", garbage.Location, ":", garbage.Pool, ":", p.ObjectId)
}
Expand Down

0 comments on commit 41bdc2b

Please sign in to comment.