Skip to content

Commit b5e59c2

Browse files
authored
Log records when release to pool failed. (#5306)
1 parent 257a5a8 commit b5e59c2

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/RedisConnection.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,18 @@ public function close(): bool
146146

147147
public function release(): void
148148
{
149-
if ($this->database && $this->database != $this->config['db']) {
150-
// Select the origin db after execute select.
151-
$this->select($this->config['db']);
152-
$this->database = null;
149+
try {
150+
if ($this->database && $this->database != $this->config['db']) {
151+
// Select the origin db after execute select.
152+
$this->select($this->config['db']);
153+
$this->database = null;
154+
}
155+
parent::release();
156+
} catch (Throwable $exception) {
157+
if ($this->container->has(StdoutLoggerInterface::class) && $logger = $this->container->get(StdoutLoggerInterface::class)) {
158+
$logger->critical('Release connection failed, caused by ' . $exception);
159+
}
153160
}
154-
parent::release();
155161
}
156162

157163
public function setDatabase(?int $database): void

0 commit comments

Comments
 (0)