Repository navigation
Description
Describe the bug
redis sentinel is having 100% cpu usage. we are using redis-ha helm chart version 4.12.15 under default configuration but we have increased resource requests and limits by a significant amount. The redis version used by us is 6.0.7.
To reproduce
I'm not sure if it can be reproduced by anyone else.
Even after redis restart, one or two sentinel reaches 100% CPU utilization.
Other redis metrics are fine and seems okay.
Expected behavior
Sentinel should be taking so much CPU.
Additional information
I ran strace on one of the sentinel and found this:
1 09:20:08 recvfrom(11, 0x7ffd55fab4a0, 16384, 0, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
1 09:20:08 recvfrom(10, 0x7ffd55fab4a0, 16384, 0, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
1 09:20:08 epoll_pwait(5, [{events=EPOLLERR, data={u32=11, u64=11}}, {events=EPOLLERR, data={u32=10, u64=10}}], 10128, 8, NULL, 😎 = 2
This seems like a repeating pattern; where redis is trying to read from two sockets and failing continuously and this followed by a epoll_wait. It happens more than 100x times in a second.
socket 11 and 10 seems to point to a connection with the redis process for this sentinel. To be exact it points to the ClusterIP of the redis-cluster-announce pod on which sentinel was running and the port is 6379.
redis
# Server
redis_version:6.0.7
redis_git_sha1:00000000
redis_git_dirty:0
redis_build_id:4b6e03cc4dd13d7e
redis_mode:standalone
os:Linux 5.10.68-62.173.amzn2.x86_64 x86_64
arch_bits:64
multiplexing_api:epoll
atomicvar_api:atomic-builtin
gcc_version:9.3.0
process_id:1
run_id:9e5a59931ada7e4b1198b6a5beb98defb5834cc0
tcp_port:6379
uptime_in_seconds:66843
uptime_in_days:0
hz:10
configured_hz:10
lru_clock:12347300
executable:/data/redis-server
config_file:/data/conf/redis.conf
io_threads_active:0
# Clients
connected_clients:8
client_recent_max_input_buffer:2
client_recent_max_output_buffer:0
blocked_clients:0
tracking_clients:0
clients_in_timeout_table:0
# Memory
used_memory:2727256
used_memory_human:2.60M
used_memory_rss:8065024
used_memory_rss_human:7.69M
used_memory_peak:2981024
used_memory_peak_human:2.84M
used_memory_peak_perc:91.49%
used_memory_overhead:2137792
used_memory_startup:803016
used_memory_dataset:589464
used_memory_dataset_perc:30.63%
allocator_allocated:2827152
allocator_active:3174400
allocator_resident:6668288
total_system_memory:66245685248
total_system_memory_human:61.70G
used_memory_lua:48128
used_memory_lua_human:47.00K
used_memory_scripts:3072
used_memory_scripts_human:3.00K
number_of_cached_scripts:4
maxmemory:0
maxmemory_human:0B
maxmemory_policy:volatile-lru
allocator_frag_ratio:1.12
allocator_frag_bytes:347248
allocator_rss_ratio:2.10
allocator_rss_bytes:3493888
rss_overhead_ratio:1.21
rss_overhead_bytes:1396736
mem_fragmentation_ratio:2.96
mem_fragmentation_bytes:5339328
mem_not_counted_for_evict:0
mem_replication_backlog:1048576
mem_clients_slaves:0
mem_clients_normal:135888
mem_aof_buffer:0
mem_allocator:jemalloc-5.1.0
active_defrag_running:0
lazyfree_pending_objects:0
# Persistence
loading:0
rdb_changes_since_last_save:23
rdb_bgsave_in_progress:0
rdb_last_save_time:1639737083
rdb_last_bgsave_status:ok
rdb_last_bgsave_time_sec:0
rdb_current_bgsave_time_sec:-1
rdb_last_cow_size:524288
aof_enabled:0
aof_rewrite_in_progress:0
aof_rewrite_scheduled:0
aof_last_rewrite_time_sec:-1
aof_current_rewrite_time_sec:-1
aof_last_bgrewrite_status:ok
aof_last_write_status:ok
aof_last_cow_size:0
module_fork_in_progress:0
module_fork_last_cow_size:0
# Stats
total_connections_received:20058
total_commands_processed:491483
instantaneous_ops_per_sec:5
total_net_input_bytes:33351575
total_net_output_bytes:275568645
instantaneous_input_kbps:0.54
instantaneous_output_kbps:1.59
rejected_connections:0
sync_full:0
sync_partial_ok:0
sync_partial_err:0
expired_keys:0
expired_stale_perc:0.00
expired_time_cap_reached_count:0
expire_cycle_cpu_milliseconds:0
evicted_keys:0
keyspace_hits:0
keyspace_misses:0
pubsub_channels:1
pubsub_patterns:0
latest_fork_usec:331
migrate_cached_sockets:0
slave_expires_tracked_keys:0
active_defrag_hits:0
active_defrag_misses:0
active_defrag_key_hits:0
active_defrag_key_misses:0
tracking_total_keys:0
tracking_total_items:0
tracking_total_prefixes:0
unexpected_error_replies:0
total_reads_processed:501438
total_writes_processed:1017489
io_threaded_reads_processed:0
io_threaded_writes_processed:0
# Replication
role:slave
master_host:172.20.61.168
master_port:6379
master_link_status:up
master_last_io_seconds_ago:0
master_sync_in_progress:0
slave_repl_offset:226855520
slave_priority:100
slave_read_only:1
connected_slaves:0
min_slaves_good_slaves:0
master_replid:6d50a55ecc1d386809fc186708bcc56db6f92765
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:226855520
second_repl_offset:-1
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:225806945
repl_backlog_histlen:1048576
# CPU
used_cpu_sys:81.727130
used_cpu_user:54.375754
used_cpu_sys_children:0.204695
used_cpu_user_children:0.501349
# Modules
# Cluster
cluster_enabled:0
# Keyspace
db0:keys=2861,expires=0,avg_ttl=0
sentinel
127.0.0.1:26379> info
# Server
redis_version:6.0.7
redis_git_sha1:00000000
redis_git_dirty:0
redis_build_id:4b6e03cc4dd13d7e
redis_mode:sentinel
os:Linux 5.10.68-62.173.amzn2.x86_64 x86_64
arch_bits:64
multiplexing_api:epoll
atomicvar_api:atomic-builtin
gcc_version:9.3.0
process_id:1
run_id:0919ce29eb1b7f9dce36cea0a2eb73bf1740939c
tcp_port:26379
uptime_in_seconds:66926
uptime_in_days:0
hz:11
configured_hz:10
lru_clock:12347383
executable:/data/redis-sentinel
config_file:/data/conf/sentinel.conf
io_threads_active:0
# Clients
connected_clients:4
client_recent_max_input_buffer:2
client_recent_max_output_buffer:0
blocked_clients:0
tracking_clients:0
clients_in_timeout_table:0
# CPU
used_cpu_sys:30052.725830
used_cpu_user:9940.032902
used_cpu_sys_children:0.000000
used_cpu_user_children:0.005161
# Stats
total_connections_received:8925
total_commands_processed:200173
instantaneous_ops_per_sec:5
total_net_input_bytes:11111722
total_net_output_bytes:1205818
instantaneous_input_kbps:0.35
instantaneous_output_kbps:0.03
rejected_connections:0
sync_full:0
sync_partial_ok:0
sync_partial_err:0
expired_keys:0
expired_stale_perc:0.00
expired_time_cap_reached_count:0
expire_cycle_cpu_milliseconds:772
evicted_keys:0
keyspace_hits:0
keyspace_misses:0
pubsub_channels:1
pubsub_patterns:0
latest_fork_usec:0
migrate_cached_sockets:0
slave_expires_tracked_keys:0
active_defrag_hits:0
active_defrag_misses:0
active_defrag_key_hits:0
active_defrag_key_misses:0
tracking_total_keys:0
tracking_total_items:0
tracking_total_prefixes:0
unexpected_error_replies:0
total_reads_processed:204104
total_writes_processed:195182
io_threaded_reads_processed:0
io_threaded_writes_processed:0
# Sentinel
sentinel_masters:1
sentinel_tilt:0
sentinel_running_scripts:0
sentinel_scripts_queue_length:0
sentinel_simulate_failure_flags:0
master0:name=mymaster,status=ok,address=172.20.61.168:6379,slaves=2,sentinels=3
Any tops for debugging this?
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
betermieux commentedon Nov 4, 2022
Same problem here.
After a few weeks of usage the slave sentinels spike 100% cpu, the master sentinel is idle.
I am using the redis-ha chart from https://dandydeveloper.github.io/charts
Let me know if I can provide more information to this issue.
oranagra commentedon Nov 5, 2022
can you run
pstackorgdb -batch -ex "bt" -p <pid>a few times so we know which code path runs in a loop?anything you can tell us about the configuration so we can reproduce it? which version are you using?
@moticless PTAL.
moticless commentedon Nov 6, 2022
@sedflix ,
According to INFO you are using rather old version (6.0.7).
Can you try newer version?
@oranagra made some fix that might be related to your issue:
Fix busy loop in ae.c when timer event is about to fire (#8764)
betermieux commentedon Nov 7, 2022
Due to a reboot the sentinel was restarted and is currently not using 100% cpu any more. I will have to wait until it happens again.
I am using docker image
redis:7.0.4-alpine3.16. Since the containers are running on a locked down Fedora CoreOS machine, I will have to debug them with a parallel container running gdb, but this should pose no problem.yevhen-harmonizehr commentedon Nov 16, 2022
Faced same issue today on 3-node cluster. Restart of single pod didn't help. Only scale to 0 and scale back to 3 nodes solved the issue.
oranagra commentedon Nov 17, 2022
@yevhen-harmonizehr please specify which version you're using.
yevhen-harmonizehr commentedon Nov 17, 2022
redis:7.0.5-alpine
oranagra commentedon Nov 20, 2022
so it can't be the above mentioned fix, which was part of 6.2.
if anyone reproduces this again (regardless of the version), we'd love to get some info.
see the instructions i posted here #9956 (comment)
kfirfer commentedon Nov 21, 2022
Its reproducing with this helm chart:
https://artifacthub.io/packages/helm/dandydev-charts/redis-ha
Tried multiple versions of redis ( 6.X + 7.X )
Its doesn't reproducing all the times
around 1 of every 3 times its reproduces
Some info:
Inside the sentinel container:
Its 24% cause the vm machine is 4 cores (so its 100% of 1 core)
lsof sentinel container:
oranagra commentedon Nov 21, 2022
i'd like a stack trace to see what it's doing.
you can maybe do that with the instructions here #9956 (comment)
or if you're willing to kill the process, then
kill -11 <pid>will cause it to print the trace to the log file.the first method is preferred since you can take several samples.
kfirfer commentedon Nov 21, 2022
@oranagra
Running as 'root' and he doesnt shows the file and line number
Idk why
kfirfer commentedon Nov 21, 2022
@oranagra
Tried with bullseye docker image and he gives me more info:
The Stacktraces running on sentinel that uses high cpu for no reason
kfirfer commentedon Nov 21, 2022
Running multiple times:
oranagra commentedon Nov 21, 2022
thanks. this is useful.
@michael-grunder can you take a look? any reason why redisNetRead will eat CPU, or do a blocking read (following an epoll indication that it's readable)?
tillkruss commentedon Nov 22, 2022
No, he’s busy fixing macOS bugs.
34 remaining items
harry91 commentedon Nov 2, 2024
We encountered the same problem and get the same gdb output as @kfirfer pasted above.
pfaelzerchen commentedon Nov 19, 2024
I also encountered the same problem, but only with the redis-ha instance that was deployed by the argo-cd helm chart (which uses
dandydev/redis-ha). My deployments made with the bitnami redis chart do not encounter this problem.Maybe this can be of any help. I am a newbie and do not really know where I would have to look into when comparing both deployments.
nomarek commentedon Jan 24, 2025
From my observations, this problem only occurs on dandydev/redis-ha, but not on bitnami/redis. The dandydev chart uses a Redis distribution based on Alpine Linux, while Bitnami uses Debian. I suspect that this problem is strictly related to musl libc on Alpine. The comments in this issue seem to confirm this, as practically everyone here mentions Alpine.
bootc commentedon Jan 24, 2025
Sorry @nomarek but this definitely also occurs in the Debian-based Redis images. I also had this theory a while back and switched to Debian-based images using the chart just to have the problem continue to occur. It also happens when using Valkey instead of Redis.
Quanalogy commentedon Feb 18, 2025
we're also affected by this bug and using dandy.
We've noticed that killing the pod can resolve the issue temporarily however in some instances it returns after 15-30 minutes.
jortkoopmans commentedon Feb 18, 2025
@Quanalogy ; a pod kill might help temporarily. But a less disruptive but equally temporary approach is to reset the sentinel of the problematic pod from the redis-cli container, with command;
Replace
<mymaster>with your actual master name (this depends on your specific use case, you can run sentinels masters to view your masters).Note these are all workarounds adding to the majority of comments in this thread about helping others dealing with it.
My hopes are still with a RCA 🙏 , guided by the repro steps from @Sven1410 ; #9956 (comment)
It might end up being specifically related to dandy helm chart (?). Speculating; preStop lifecycle hooks between sentinel and redis-cli containers seem to be differing, could this be causing problems on the remaining sentinels? This is structured quite differently on bitnami charts. But this should also become clear from RCA, probably we're still hitting a real bug as processes gone rogue should not be possible.
l-maia commentedon Dec 2, 2025
I'm no expert on the Redis source code, but i've noticed that it keeps polling even after errors in the file descriptor.
I've made a fork with a minor change on how redisAeReadEvent is implemented in sentinel and published a docker image build with the changes as lumaia/redis:7.4.7.
More testing is needed, but it seems for now that I'm not able to reproduce the error in that image when restarting the pods in my existing cluster.
peter-svensson commentedon Sep 4, 2026
Still present on redis 8.2.3-alpine (Argo CD 3.5.2 HA manifest,
redis-hachart layout, 3 sentinels,quorum 2), on Kubernetes 1.36 / arm64 (Ubuntu 24.04).Adding one data point that I think contradicts the working assumption in this thread and in argoproj/argo-cd#16360, plus some counter evidence that may narrow the search.
The spin is acquired at runtime, with no restart and no rolling update
The consensus here and in the Argo CD issue is that it appears "after a rolling update or pod restarts". That is not what I observed. Across two observations two days apart on the same StatefulSet:
server-0went from quiet to spinning between those dates while reportingrestartCount=0, with the same process running since 2026-08-24 (10-day uptime,startedAtunchanged). No rolling update, no node event, no pod restart, no config change — and the pod'sstartedAtandrestartCountare the evidence rather than my memory of what was deployed. Meanwhileserver-2was restarted on 09-03 for unrelated reasons and came back quiet.So a restart clears it and a fresh process can acquire it later, spontaneously. That matters for reproduction: recipes that restart pods and then watch for the spin are testing a sufficient trigger, not a necessary one. It also explains why the
postStart: sleep 30; sentinel resetworkaround (argoproj/argo-cd#16360, merged as argoproj/argo-cd#20645, which we render) is insufficient rather than merely unreliable — it only fires once, 30s after container start, so it cannot address a state entered days later.Counter evidence
Sampled on a spinning sentinel (
used_cpu_sys/used_cpu_useragree with/proc/1/statto within one tick):versus a healthy sentinel in the same StatefulSet, same image, same config, same quorum:
The
voluntary_ctxt_switchesdelta being exactly zero while the process burns a full core is, I think, the sharpest signal available without gdb: the process never once blocks. The 28M accumulated count is historical, from when it was healthy. Process state sampledR10/10 times with/proc/<pid>/syscallempty at each sample, so each individual sample caught it in userspace — but with stime exceeding utime overall, the loop is clearly still transiting the kernel constantly. That is consistent with theepoll_waitbacktraces posted earlier in this thread rather than a pure userspace loop: a tight, fast cycle throughaeApiPollwhere any given sample is likely to land on the userspace side.Other things ruled out on our instance: memory flat at 3–7Mi (no leak), 21 file descriptors and stable, all sockets
ESTABLISHEDwith empty queues, nomaxclients/ulimit pressure, and only the main thread burns CPU (tid=1; thebio_*andjemalloc_bg_thdthreads are all at 0).Notably the sentinel stays functionally correct throughout —
master0:...status=ok,slaves=2,sentinels=3,sentinel_tilt:0, health probes passing — and writes zero log lines while spinning. That is why this went unnoticed for 9 days here.SENTINEL RESETclears it without a restartConfirmed with a control. Ran
redis-cli -p 26379 sentinel reset argocdon one spinning sentinel and deliberately left another spinning:R→S, within 20 seconds. Quorum intact, no restart, no failover.For anyone hitting this in production, that is a considerably cheaper mitigation than
kubectl rollout restart— though notesentinelResetMaster()also clears the peer dict, theO_DOWN/S_DOWNand failover-in-progress flags, and setsfailover_start_time = 0("We can failover again ASAP", sentinel.c:1533), so running it unconditionally on a timer across every replica is not free. We gate ours on measured CPU so it only ever fires on a sentinel that is already spinning.Happy to pull gdb backtraces or run anything specific the next time one goes hot — we now alert on it, so we should catch the next occurrence promptly rather than finding it 9 days later. Given it appears spontaneously on long-lived processes, a reproducer may be better built around leaving a quorum idle for days than around restart churn.
Fix Sentinel 100% CPU busy-loop on async socket error (EPOLLERR) (#15107
Fix Linux TCP connect error queue in hiredis (#15917)