Skip to content

Commit afe79f7

Browse files
committed
wip
1 parent a47b7de commit afe79f7

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

system/Database/Config.php

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,10 +173,20 @@ public static function resetForWorkerMode(WorkerMode $config): void
173173
break;
174174

175175
case 'keep-alive':
176-
while ($connection->transDepth > 0) {
177-
$connection->transRollback();
176+
$maxAttempts = 10; // Prevent infinite loop
177+
$attempts = 0;
178+
179+
while ($connection->transDepth > 0 && $attempts < $maxAttempts) {
180+
if (! $connection->transRollback()) {
181+
log_message('error', "Database transaction rollback failed for group: {$group}");
182+
break;
183+
}
184+
$attempts++;
185+
}
186+
187+
if ($connection->transDepth > 0) {
188+
log_message('warning', "Database connection has uncommitted transactions after cleanup: {$group}");
178189
}
179-
$connection->transDepth = 0;
180190

181191
if (! $connection->ping()) {
182192
log_message('info', "Database connection dead, reconnecting: {$group}");

0 commit comments

Comments
 (0)