коммит произвёл
GitHub
родитель
80c846412d
Коммит
82e27982d0
@@ -426,7 +426,7 @@ func (ss *SqlSupplier) DoesTableExist(tableName string) bool {
|
||||
|
||||
} else if ss.DriverName() == model.DATABASE_DRIVER_SQLITE {
|
||||
count, err := ss.GetMaster().SelectInt(
|
||||
`SELECT name FROM sqlite_master WHERE type='table' AND name=?`,
|
||||
`SELECT count(name) FROM sqlite_master WHERE type='table' AND name=?`,
|
||||
tableName,
|
||||
)
|
||||
|
||||
@@ -1004,6 +1004,23 @@ func (ss *SqlSupplier) GetAllConns() []*gorp.DbMap {
|
||||
return all
|
||||
}
|
||||
|
||||
// RecycleDBConnections closes active connections by setting the max conn lifetime
|
||||
// to d, and then resets them back to their original duration.
|
||||
func (ss *SqlSupplier) RecycleDBConnections(d time.Duration) {
|
||||
// Get old time.
|
||||
originalDuration := time.Duration(*ss.settings.ConnMaxLifetimeMilliseconds) * time.Millisecond
|
||||
// Set the max lifetimes for all connections.
|
||||
for _, conn := range ss.GetAllConns() {
|
||||
conn.Db.SetConnMaxLifetime(d)
|
||||
}
|
||||
// Wait for that period with an additional 2 seconds of scheduling delay.
|
||||
time.Sleep(d + 2*time.Second)
|
||||
// Reset max lifetime back to original value.
|
||||
for _, conn := range ss.GetAllConns() {
|
||||
conn.Db.SetConnMaxLifetime(originalDuration)
|
||||
}
|
||||
}
|
||||
|
||||
func (ss *SqlSupplier) Close() {
|
||||
ss.master.Db.Close()
|
||||
for _, replica := range ss.replicas {
|
||||
|
||||
Ссылка в новой задаче
Block a user