mirror of
https://github.com/nextcloud/server.git
synced 2026-06-08 16:26:59 -04:00
Merge pull request #47528 from nextcloud/backport/47510/stable30
[stable30] fix(db): Increase log level for very slow transactions
This commit is contained in:
commit
656fdef932
1 changed files with 29 additions and 2 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in a new issue