prev_error_count needs to be thread local

Former-commit-id: 4abede1c40db1dfb4235b9aa1e3177678c5304b1
This commit is contained in:
malavan 2021-09-23 17:41:28 +00:00
parent ef1ca1be9b
commit 1f4c9e6a75
4 changed files with 5 additions and 6 deletions

View File

@ -159,7 +159,6 @@ static robj_roptr lookupKeyConst(redisDb *db, robj *key, int flags) {
* expiring our key via DELs in the replication link. */
robj_roptr lookupKeyReadWithFlags(redisDb *db, robj *key, int flags) {
robj_roptr val;
//serverAssert(GlobalLocksAcquired());
if (expireIfNeeded(db,key) == 1) {
/* If we are in the context of a master, expireIfNeeded() returns 1

View File

@ -530,7 +530,7 @@ void addReplyErrorLength(client *c, const char *s, size_t len) {
/* Do some actions after an error reply was sent (Log if needed, updates stats, etc.) */
void afterErrorReply(client *c, const char *s, size_t len, int severity = ERR_CRITICAL) {
/* Increment the global error counter */
/* Increment the thread error counter */
serverTL->stat_total_error_replies++;
/* Increment the error stats
* If the string already starts with "-..." then the error prefix

View File

@ -4357,7 +4357,6 @@ void call(client *c, int flags) {
int client_old_flags = c->flags;
struct redisCommand *real_cmd = c->cmd;
serverAssert(((flags & CMD_CALL_ASYNC) && (c->cmd->flags & CMD_READONLY)) || GlobalLocksAcquired());
long long prev_err_count;
serverTL->fixed_time_expire++;
@ -4388,7 +4387,7 @@ void call(client *c, int flags) {
/* Call the command. */
dirty = g_pserver->dirty;
prev_err_count = serverTL->stat_total_error_replies;
serverTL->prev_err_count = serverTL->stat_total_error_replies;
incrementMvccTstamp();
elapsedStart(&call_timer);
try {
@ -4413,7 +4412,7 @@ void call(client *c, int flags) {
* We leverage a static variable (prev_err_count) to retain
* the counter across nested function calls and avoid logging
* the same error twice. */
if ((serverTL->stat_total_error_replies - prev_err_count) > 0) {
if ((serverTL->stat_total_error_replies - serverTL->prev_err_count) > 0) {
real_cmd->failed_calls++;
}
@ -4579,7 +4578,7 @@ void call(client *c, int flags) {
__atomic_fetch_add(&g_pserver->stat_numcommands, 1, __ATOMIC_RELAXED);
serverTL->fixed_time_expire--;
prev_err_count = serverTL->stat_total_error_replies;
serverTL->prev_err_count = serverTL->stat_total_error_replies;
if (!(flags & CMD_CALL_ASYNC)) {
/* Record peak memory after each command and before the eviction that runs

View File

@ -2020,6 +2020,7 @@ struct redisServerThreadVars {
GarbageCollectorCollection::Epoch gcEpoch;
const redisDbPersistentDataSnapshot **rgdbSnapshot = nullptr;
long long stat_total_error_replies; /* Total number of issued error replies ( command + rejected errors ) */
long long prev_err_count; /* per thread marker of exisiting errors during a call */
bool fRetrySetAofEvent = false;
bool modulesEnabledThisAeLoop = false; /* In this loop of aeMain, were modules enabled before
the thread went to sleep? */