-
Notifications
You must be signed in to change notification settings - Fork 11.7k
Description
Laravel Version
12.37.0
PHP Version
8.3
Database Driver & Version
No response
Description
I’ve noticed that both the CacheFailedOver and QueueFailedOver events in Laravel are triggered with every cache read or queue operation, even if there isn't an actual failover happening. This could lead to unnecessary event firing, especially in high-traffic systems, where it might cause excess logging, notifications, or processing.
Suggested Improvement:
It would be really helpful if these events were only triggered when a true failover occurs. For instance, when the primary cache or queue connection fails, and Laravel falls back to the secondary connection, that’s when the event should fire. This would make the events more meaningful, reducing the noise caused by cache or queue operations that don’t actually involve failovers.
Use Case:
Reducing Unnecessary Events: It would be great if events were only triggered when there’s an actual failover, which would help minimize unnecessary logging.
Improved Performance: This change would help prevent unnecessary system overhead from processing events during normal operations.
Clearer Monitoring: Triggering the events only when the fallback happens would make monitoring more accurate and provide more meaningful alerts.
Current Behavior:
Right now, the events seem to fire every time a cache or queue operation takes place, regardless of whether the system is actually falling back to a secondary store.
Possible Solution:
It might be useful for the events to be triggered only when there’s a real connection failure that leads to the fallback, rather than firing on every operation. This could help ensure the events are more focused and relevant.
Steps To Reproduce
Configure failover for cache/queue in .env:
CACHE_DRIVER=failover
QUEUE_CONNECTION=failover
Set up failover in config/cache.php and config/queue.php with redis as the primary store/connection and database as the fallback.
Simulate Redis failure (disconnect or stop Redis service).
Run a cache or queue operation (e.g., Cache::get('key') or dispatch a job).
Expected Behavior:
The CacheFailedOver and QueueFailedOver events should only fire when an actual failover happens.
Current Behavior:
The events fire on every cache/queue operation, even if no failover occurs.