Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix(db): Increase log level for very slow transactions
Signed-off-by: Christoph Wurst <[email protected]>
  • Loading branch information
ChristophWurst committed Apr 2, 2025
commit 231373106bddf75fa823ce1f5eaa8657939cc199
31 changes: 29 additions & 2 deletions lib/private/DB/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
use OC\SystemConfig;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\Diagnostics\IEventLogger;
use OCP\ILogger;
use OCP\IRequestId;
use OCP\PreConditionNotMetException;
use OCP\Profiler\IProfiler;
Expand Down Expand Up @@ -737,7 +738,20 @@ public function commit() {
$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;
Expand All @@ -750,7 +764,20 @@ public function rollBack() {
$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;
Expand Down
Loading