redis/tests/integration
debing.sun 7fb02029f5
Fix mem_clients_normal accounting drift when discarding a cached master (#15309)
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).
2026-06-22 09:49:57 +08:00
..
aof-multi-part.tcl AOF offset info (#13773) 2025-02-13 17:31:40 +08:00
aof-race.tcl Stabilization and improvements around aof tests (#12626) 2023-10-02 08:20:53 +03:00
aof.tcl Fixes an issue where EXEC checks ACL during AOF loading (#14545) 2025-11-22 11:52:31 +08:00
block-repl.tcl Attempt to solve MacOS CI issues in GH Actions (#12013) 2023-04-12 09:19:21 +03:00
convert-ziplist-hash-on-load.tcl Replace all usage of ziplist with listpack for t_hash (#8887) 2021-08-10 09:18:49 +03:00
convert-ziplist-zset-on-load.tcl Replace all usage of ziplist with listpack for t_zset (#9366) 2021-09-09 18:18:53 +03:00
convert-zipmap-hash-on-load.tcl Replace all usage of ziplist with listpack for t_hash (#8887) 2021-08-10 09:18:49 +03:00
corrupt-dump-fuzzer.tcl Hold GCRA out of the release (#15191) 2026-05-14 16:31:25 +03:00
corrupt-dump.tcl Validate stream entries_added/entries_read on RDB/RESTORE load (#15308) 2026-06-09 14:13:57 +03:00
dismiss-mem.tcl Implement the new Redis Array type (#15162) 2026-05-14 00:56:44 +08:00
failover.tcl Fix test assertion except from TSAN case (#14852) 2026-03-06 13:11:38 +02:00
logging.tcl Hide user data from log (#13400) 2024-07-09 18:54:18 +08:00
psync2-master-restart.tcl Handle primary/replica clients in IO threads (#14335) 2026-01-21 16:19:12 +02:00
psync2-pingoff.tcl Fix race condition in psync2-pingoff test (#9712) 2021-11-01 16:07:08 +02:00
psync2-reg.tcl Improve test suite to handle external servers better. (#9033) 2021-06-09 15:13:24 +03:00
psync2.tcl Tests: Do not save an RDB by default and add a SIGTERM default AOFRW test (#12064) 2023-04-18 16:14:26 +03:00
rdb.tcl Fix DB hash tables not expanding during RDB load (#14789) 2026-02-14 15:18:08 +08:00
redis-benchmark.tcl Fix divide-by-zero in redis-benchmark and redis-cli (#14371) 2026-03-18 19:57:58 +08:00
redis-cli.tcl Fix AUTH failure on URIs with empty username in redis-cli (#15255) 2026-06-02 09:29:56 +08:00
replication-2.tcl Attempt to solve MacOS CI issues in GH Actions (#12013) 2023-04-12 09:19:21 +03:00
replication-3.tcl Introduce DEBUG_DEFRAG compilation option to allow run test with activedefrag when allocator is not jemalloc (#14326) 2025-09-10 12:52:20 +08:00
replication-4.tcl optimize spopwithcount propagation (#12082) 2023-05-22 10:27:14 +03:00
replication-buffer.tcl Handle primary/replica clients in IO threads (#14335) 2026-01-21 16:19:12 +02:00
replication-iothreads.tcl Handle primary/replica clients in IO threads (#14335) 2026-01-21 16:19:12 +02:00
replication-psync.tcl Introduce flushdb option for repl-diskless-load (#14596) 2025-12-15 11:25:53 +08:00
replication-rdbchannel.tcl Introduce DEBUG_DEFRAG compilation option to allow run test with activedefrag when allocator is not jemalloc (#14326) 2025-09-10 12:52:20 +08:00
replication.tcl Fix mem_clients_normal accounting drift when discarding a cached master (#15309) 2026-06-22 09:49:57 +08:00
shutdown.tcl Fix shutdown blocked client not being properly reset after shutdown cancellation (#14420) 2025-10-15 14:13:40 +08:00