aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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;