diff options
author | Christoph Wurst <christoph@winzerhof-wurst.at> | 2024-08-27 10:03:35 +0200 |
---|---|---|
committer | Andy Scherzinger <info@andy-scherzinger.de> | 2024-09-04 13:25:34 +0200 |
commit | 3a1c4fd68687589812532e834678e0ef3a43037c (patch) | |
tree | 862cf6ad9b2953eaaaeffb8015a2a5a93199cce7 | |
parent | d76b7633d748f7bb5eaa0163e080ec2e9d0066b6 (diff) | |
download | nextcloud-server-backport/47510/stable29.tar.gz nextcloud-server-backport/47510/stable29.zip |
fix(db): Increase log level for very slow transactionsbackport/47510/stable29
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
[skip ci]
-rw-r--r-- | lib/private/DB/Connection.php | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/lib/private/DB/Connection.php b/lib/private/DB/Connection.php index 6e2db8e47bc..f9d126e4f68 100644 --- a/lib/private/DB/Connection.php +++ b/lib/private/DB/Connection.php @@ -737,7 +737,20 @@ class Connection extends PrimaryReadReplicaConnection { $this->transactionBacktrace = null; $this->transactionActiveSince = null; if ($timeTook > 1) { - $this->logger->debug('Transaction took ' . $timeTook . 's', ['exception' => new \Exception('Transaction took ' . $timeTook . 's')]); + $logLevel = match (true) { + $timeTook > 20 * 60 => ILogger::ERROR, + $timeTook > 5 * 60 => ILogger::WARN, + $timeTook > 10 => ILogger::INFO, + default => ILogger::DEBUG, + }; + $this->logger->log( + $logLevel, + 'Transaction took ' . $timeTook . 's', + [ + 'exception' => new \Exception('Transaction took ' . $timeTook . 's'), + 'timeSpent' => $timeTook, + ] + ); } } return $result; @@ -750,7 +763,20 @@ class Connection extends PrimaryReadReplicaConnection { $this->transactionBacktrace = null; $this->transactionActiveSince = null; if ($timeTook > 1) { - $this->logger->debug('Transaction rollback took longer than 1s: ' . $timeTook, ['exception' => new \Exception('Long running transaction rollback')]); + $logLevel = match (true) { + $timeTook > 20 * 60 => ILogger::ERROR, + $timeTook > 5 * 60 => ILogger::WARN, + $timeTook > 10 => ILogger::INFO, + default => ILogger::DEBUG, + }; + $this->logger->log( + $logLevel, + 'Transaction rollback took longer than 1s: ' . $timeTook, + [ + 'exception' => new \Exception('Long running transaction rollback'), + 'timeSpent' => $timeTook, + ] + ); } } return $result; |