Comments (13)
Don't use defer in a loop.
Just call cancel() after PingContext returns.
from mysql.
It is unlimited by default. So increasing context timeout also increase timeout to get connection from pool.
from mysql.
I can't compile jpeg.
Post a runnable source code.
from mysql.
func mysql_check_connection() {
logger.Info("mysql_check_connection call")
//db.Execute("select 42")
for {
var errMy error
ctx, _ := context.WithTimeout(context.Background(), 40*time.Second)
errMy = db.PingContext(ctx)
if errMy != nil {
stats := db.Stats()
fields := logrus.Fields{
"MaxOpenConnections": stats.MaxOpenConnections,
"OpenConnections": stats.OpenConnections,
"InUse": stats.InUse,
"Idle": stats.Idle,
"WaitCount": stats.WaitCount,
"WaitDuration": stats.WaitDuration.String(),
"MaxIdleClosed": stats.MaxIdleClosed,
"MaxLifetimeClosed": stats.MaxLifetimeClosed,
"err": errMy,
}
logger.ErrorWithFields(fields, "ConMysql error on mysql_check_connection Err : ")
Heartbeat = false
//fmt.Println(" Heartbeat change to false :", Heartbeat)
/**/
mutex.Lock()
db.Close()
start()
mutex.Unlock()
//go start()
return
}
Heartbeat = true
time.Sleep(3 * time.Second)
}
}
from mysql.
how can increase total time blocked waiting for a new connection?
from mysql.
Oh! You don't call cancel func.
You are leaking many contexts.
from mysql.
do you mean this change?
ctx, cancel := context.WithTimeout(context.Background(), 40*time.Second)
defer cancel() // Call cancel function to release resources when the function returns
from mysql.
i change it
ctx, cancel := context.WithTimeout(context.Background(), 40*time.Second)
errMy = db.PingContext(ctx)
cancel()
how can increase total time blocked waiting for a new connection?
from mysql.
I cannot understand what you mean.
If you want to be blocked long time, set max open connection to 1 and query "SELECT SLEEP(100)" from 100 goroutines.
99 goroutines need to wait 100 sec.
98 goroutines need to wait another 100 sec.
...
from mysql.
no please see this db stat
{
"Idle": 0,
"InUse": 15,
"MaxIdleClosed": 0,
"MaxLifetimeClosed": 57,
"MaxOpenConnections": 15,
"OpenConnections": 15,
"WaitCount": 141,
"WaitDuration": "2m39.604195004s",
}
my MaxOpenConnections was equaled to OpenConnections and WaitDuration is 2m39
how can i increase WaitDuration to 10 m ?
from mysql.
Maybe, you misunderstand it.
Wait duration in db stat is what I said.
Total time for waiting connection from pool.
from mysql.
ok but is there any time limit for waiting connection from pool?
from mysql.
Anyway, here is issue tracker, not user forum.
from mysql.
Related Issues (20)
- mysql startWatcher panic error HOT 3
- Bizarre hanging issue in rows.Close() HOT 7
- Can't Install, bug in edwards25519/scalar.go HOT 1
- Likely race that can prevent to recycle closed connections HOT 5
- Return timeout error instead of Invalid connection err when read packet network timeout HOT 5
- 保存时报错:Prepared statement contains too many placeholders
- SEGV writing packet HOT 1
- Connection liveness/goodeness check and AWS Aurora HOT 1
- Data race between mysqlConn watcher and okHandler during context cancellation HOT 3
- v1.6.0 get error
- Data race between mysqlConn.cleanup() and writeHandshakeResponsePacket HOT 2
- MaxOpenConns is not working
- Receiving "(using password: NO)" when password was given HOT 2
- Why must use port 3306?
- Scanner should return one of int64,float64,bool,[]byte,string,time.Time,nil , but I got uint64 HOT 3
- Do I need logic backup mysql data using mysqldump while I have master-slave mysql cluster.
- Improve ErrBadConn
- closing bad idle connection: EOF HOT 3
- Can I use this library to parse these byte sequences into the MySQL protocol?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mysql.