MM-24310: Recycle DB connections properly (#14378)

Automatic Merge
Этот коммит содержится в:
Agniva De Sarker
2020-05-08 10:33:54 +05:30
коммит произвёл GitHub
родитель 80c846412d
Коммит 82e27982d0
6 изменённых файлов: 77 добавлений и 11 удалений

Просмотреть файл

@@ -161,18 +161,14 @@ func (a *App) InvalidateAllCachesSkipSend() {
}
func (a *App) RecycleDatabaseConnection() {
oldStore := a.Srv().Store
mlog.Info("Attempting to recycle database connections.")
mlog.Warn("Attempting to recycle the database connection.")
a.Srv().Store = a.Srv().newStore()
a.Srv().Jobs.Store = a.Srv().Store
// This works by setting 10 seconds as the max conn lifetime for all DB connections.
// This allows in gradually closing connections as they expire. In future, we can think
// of exposing this as a param from the REST api.
a.Srv().Store.RecycleDBConnections(10 * time.Second)
if a.Srv().Store != oldStore {
time.Sleep(20 * time.Second)
oldStore.Close()
}
mlog.Warn("Finished recycling the database connection.")
mlog.Info("Finished recycling database connections.")
}
func (a *App) TestSiteURL(siteURL string) *model.AppError {