-
Notifications
You must be signed in to change notification settings - Fork 334
Open
Description
Octane Version
2.13.5
Laravel Version
12.50.0
PHP Version
8.3.29
What server type are you using?
Open Swoole
Server Version
25.2.0
Database Driver & Version
MySQL 8.4 (Percona)
Description
When using Redis as a cache store, Octane is keeping Redis connections open indefinitely even after a request has been terminated. This is leading to incremental Redis connections that get opened by Octane, and never closed.
We've implemented a listener and added to Octane's RequestTerminated section and this is working much better.
I believe this should be implemented into Octane's core code and config file so others don't get the issue.
Our code was to do this, and add it to RequestTerminated
namespace App\Listeners\Octane;
use Illuminate\Support\Facades\Redis;
class TerminateRedisConnections
{
/**
* Handle the event.
*
* @param object $event
* @return void
*/
public function handle($event): void
{
foreach (array_keys(config('database.redis', [])) as $connection) {
if ($connection === 'options') {
continue;
}
try {
Redis::connection($connection)->disconnect();
} catch (\Throwable) {
// Best-effort cleanup; the next request will establish fresh sockets as needed.
}
}
}
}Steps To Reproduce
Redis states that connections are left open forever unless closed, but, even after specifying a timeout as per their docs this actually closes connections too quick.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels