aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorAndy Scherzinger <info@andy-scherzinger.de>2024-08-29 00:19:20 +0200
committerGitHub <noreply@github.com>2024-08-29 00:19:20 +0200
commit656fdef9321c40cfb8090546a14a4db28639d10a (patch)
tree59b39e5cdcb930ee9a3f8b8cd4387217a80d1b8a /lib
parentce0b75c89e8e92acd1cd67c10401268cbcdf13d2 (diff)
parent6d2394680cb32b1f9ddd4e75afdf3658afa4dce2 (diff)
downloadnextcloud-server-656fdef9321c40cfb8090546a14a4db28639d10a.tar.gz
nextcloud-server-656fdef9321c40cfb8090546a14a4db28639d10a.zip
Merge pull request #47528 from nextcloud/backport/47510/stable30
[stable30] fix(db): Increase log level for very slow transactions
Diffstat (limited to 'lib')
-rw-r--r--lib/private/DB/Connection.php31
1 files changed, 29 insertions, 2 deletions
diff --git a/lib/private/DB/Connection.php b/lib/private/DB/Connection.php
index 027ee3be976..1b724179f06 100644
--- a/lib/private/DB/Connection.php
+++ b/lib/private/DB/Connection.php
@@ -37,6 +37,7 @@ use OCP\DB\QueryBuilder\Sharded\IShardMapper;
use OCP\Diagnostics\IEventLogger;
use OCP\ICacheFactory;
use OCP\IDBConnection;
+use OCP\ILogger;
use OCP\IRequestId;
use OCP\PreConditionNotMetException;
use OCP\Profiler\IProfiler;
@@ -818,7 +819,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;
@@ -831,7 +845,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;