mirror of
https://github.com/predis/predis.git
synced 2026-11-10 03:36:17 +00:00
Fix connection cleanup after interrupted pipelines (#1741)
Disconnect interrupted pipeline connections before they can be reused, discard remaining commands, and reset running state after PHP errors. Preserve the original failure when connection cleanup also fails. Clear the cached connection resource when Relay is closed so the next command reconnects and replays connection initialization. This fixes client reuse after an interrupted pipeline disconnects the connection.
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
namespace Predis\Connection;
|
||||
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use Predis\Client;
|
||||
use Predis\ClientException;
|
||||
use Predis\Command\RawCommand;
|
||||
use Predis\NotSupportedException;
|
||||
@@ -455,6 +456,22 @@ class RelayConnectionTest extends PredisTestCase
|
||||
// ---- INTEGRATION TESTS --------------------------------------------- //
|
||||
// ******************************************************************** //
|
||||
|
||||
/**
|
||||
* @group connected
|
||||
*/
|
||||
public function testClientReconnectsAfterDisconnect(): void
|
||||
{
|
||||
$client = new Client($this->getParameters(), ['connections' => 'relay']);
|
||||
|
||||
$this->assertEquals('PONG', $client->ping());
|
||||
$client->disconnect();
|
||||
$this->assertFalse($client->isConnected());
|
||||
|
||||
$this->assertEquals('PONG', $client->ping());
|
||||
$this->assertTrue($client->isConnected());
|
||||
$client->disconnect();
|
||||
}
|
||||
|
||||
/**
|
||||
* @group connected
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user