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:
Agniva De Sarker
2020-05-15 14:19:46 +05:30
committed by GitHub
parent 76ed77663a
commit 21af1f49f1
2 changed files with 6 additions and 6 deletions

View File

@@ -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
}