Servers

Redis Sentinel repeatedly promotes and then re-demotes master after IO stall during AOF rewrite

Environment

Environment

Redis 6.2 cluster using AOF persistence, three Sentinels across VMs, master and two replicas on VMs with local HDD-backed storage high I/O load during nightly logrotate; during AOF BGREWRITE the master blocks for several seconds and replicas report lag and OOM-like disconnects; Sentinel elects failover then reverses within minutes.

Symptoms

Symptoms

Spikes of Redis role changes: master promoted then demoted back to original within minutes, client errors during windows, replicas show reproduction backlog growth, and AOF rewrite log shows 'Background append only file rewrite started' followed by long pause. System IO wait on host increases drastically during the rewrite.

Observations

Observations

Sentinel logs show ODOWN then FAILOVER_START and then a manual-ish reconfiguration to previous master; during the pause replication offsets diverge; disk iostat shows >200ms write latency, and dmesg shows kernel writeback pressure. Replicas periodically disconnect and reconnect leading to replication backlog growth. No kernel panics.

Already attempted

Already attempted

Raised replica-priority and adjusted min-slaves-to-write (no change), temporarily disabled AOF rewrite on master (reduced churn but unacceptable for persistence), tuned vm.dirty_ratio (experimented without durable improvement), tried upgrading Redis but environment still hits heavy disk latency windows.

Question

Question

Why is Sentinel oscillating promotions after AOF rewrite stalls, and what stable configuration stops flip-flop failovers while preserving AOF durability?

COMMUNITY RESPONSES

Verified community troubleshooting

0 replies

No answers yet..

Showing 0 of 0 community responses
AI DIAGNOSTICS

Incident analysis

Updated 4w ago• Trouble ID

Most likely causes

Master AOF BGREWRITE causes long main-thread stalls due to slow HDD I/O, making Sentinels mark master ODOWN 90%
Sentinel timeouts (down-after-milliseconds, failover-timeout) are too aggressive for the observed I/O stall window 70%
Replication backlog insufficient; replicas can't catch up after stall so Sentinels detect inconsistent topology and revert roles 55%

Summary

Sentinel uses replica reachability and replication offset to decide failover. Long AOF rewrites that block Redis main thread (or cause the master to stop acknowledging) make Sentinels mark master as ODOWN and start failover. If the master recovers quickly and replicas later rejoin with different offsets, Sentinels may reconfigure roles back, causing oscillation. Core issues: slow disk causing long AOF bgrewrite blocking/backpressure, tight Sentinel timeouts, and insufficient quorum or partial network packet loss during high IO. Resolving requires reducing AOF rewrite impact (use faster storage, disable synchronous fsync during rewrite, schedule rewrites off-peak), lengthening Sentinel down-after-milliseconds, and ensuring replicas can catch up without being removed from quorum.

Suggested Fixes

Diagnostic step 1
Move Redis AOF rewrite to faster storage (SSD) or reduce AOF rewrite frequency by tuning auto-aof-rewrite-percentage/size; test impact in staging.
Diagnostic step 2
Temporarily increase sentinel down-after-milliseconds and failover-timeout to larger values (e.g., 60s) so brief AOF-induced stalls do not trigger failover; apply on all Sentinels atomically.
Diagnostic step 3
Ensure replication backlog (repl-backlog-size) is large enough for the stall window, and check replicas' disk I/O health so they can catch up after pause.

Continue troubleshooting

Matched from the title, description and tags