File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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 }" );
You can’t perform that action at this time.
0 commit comments