mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
MM-25238: Fix system ping check to read from master (#14580)
The code was writing to master and immediately after that reading from a replica causing it to fail intermittently. Since this is not a very high-traffic table, it should be safe to read from master always.
This commit is contained in:
@@ -86,23 +86,23 @@ func getSystemPing(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
Value: currentTime,
|
||||
})
|
||||
if writeErr != nil {
|
||||
mlog.Debug("Unable to write to database.", mlog.Err(writeErr))
|
||||
mlog.Warn("Unable to write to database.", mlog.Err(writeErr))
|
||||
s[dbStatusKey] = model.STATUS_UNHEALTHY
|
||||
s[model.STATUS] = model.STATUS_UNHEALTHY
|
||||
} else {
|
||||
healthCheck, readErr := c.App.Srv().Store.System().GetByName(healthCheckKey)
|
||||
if readErr != nil {
|
||||
mlog.Debug("Unable to read from database.", mlog.Err(readErr))
|
||||
mlog.Warn("Unable to read from database.", mlog.Err(readErr))
|
||||
s[dbStatusKey] = model.STATUS_UNHEALTHY
|
||||
s[model.STATUS] = model.STATUS_UNHEALTHY
|
||||
} else if healthCheck.Value != currentTime {
|
||||
mlog.Debug("Incorrect healthcheck value", mlog.String("expected", currentTime), mlog.String("got", healthCheck.Value))
|
||||
mlog.Warn("Incorrect healthcheck value", mlog.String("expected", currentTime), mlog.String("got", healthCheck.Value))
|
||||
s[dbStatusKey] = model.STATUS_UNHEALTHY
|
||||
s[model.STATUS] = model.STATUS_UNHEALTHY
|
||||
}
|
||||
_, writeErr = c.App.Srv().Store.System().PermanentDeleteByName(healthCheckKey)
|
||||
if writeErr != nil {
|
||||
mlog.Debug("Unable to remove ping health check value from database", mlog.Err(writeErr))
|
||||
mlog.Warn("Unable to remove ping health check value from database", mlog.Err(writeErr))
|
||||
s[dbStatusKey] = model.STATUS_UNHEALTHY
|
||||
s[model.STATUS] = model.STATUS_UNHEALTHY
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user