mirror of
https://github.com/redis/redis.git
synced 2026-07-15 13:08:59 -04:00
Found by oranagra
## The problem
`freeClient()` reverses the client's contribution to
`stat_clients_type_memory` (exposed as `mem_clients_normal`) only when
`c->conn` is set:
```c
if (c->conn)
server.stat_clients_type_memory[c->last_memory_type] -= c->last_memory_usage;
```
A replica caches its master on disconnect to attempt a partial resync.
replicationCacheMaster() detaches the connection (unlinkClient) before
caching, so by the time the cached master is freed by
replicationDiscardCachedMaster(), `c->conn` is already NULL. The
subtraction is skipped, so the cached master's last accounted size is
never removed from mem_clients_normal.
## Fix
Include the cached master in the subtraction by also reversing the
contribution when the client being freed is `server.cached_master` (it
is still set at the point `replicationDiscardCachedMaster()` calls
`freeClient()`, and only cleared right after).
|
||
|---|---|---|
| .. | ||
| aof-multi-part.tcl | ||
| aof-race.tcl | ||
| aof.tcl | ||
| block-repl.tcl | ||
| convert-ziplist-hash-on-load.tcl | ||
| convert-ziplist-zset-on-load.tcl | ||
| convert-zipmap-hash-on-load.tcl | ||
| corrupt-dump-fuzzer.tcl | ||
| corrupt-dump.tcl | ||
| dismiss-mem.tcl | ||
| failover.tcl | ||
| logging.tcl | ||
| psync2-master-restart.tcl | ||
| psync2-pingoff.tcl | ||
| psync2-reg.tcl | ||
| psync2.tcl | ||
| rdb.tcl | ||
| redis-benchmark.tcl | ||
| redis-cli.tcl | ||
| replication-2.tcl | ||
| replication-3.tcl | ||
| replication-4.tcl | ||
| replication-buffer.tcl | ||
| replication-iothreads.tcl | ||
| replication-psync.tcl | ||
| replication-rdbchannel.tcl | ||
| replication.tcl | ||
| shutdown.tcl | ||