From 702a4e4f37681ff914be5eb9e3eeba350543e5fb Mon Sep 17 00:00:00 2001 From: Deon George Date: Sat, 12 Nov 2022 09:32:39 +1100 Subject: [PATCH] Attempt to catch DB errors and abort the transaction, so that the queue continues to run. --- app/Jobs/NodelistImport.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/Jobs/NodelistImport.php b/app/Jobs/NodelistImport.php index 0c1c285..4cb1a59 100644 --- a/app/Jobs/NodelistImport.php +++ b/app/Jobs/NodelistImport.php @@ -343,7 +343,14 @@ class NodelistImport implements ShouldQueue } // Save the system record - $so->save(); + try { + $so->save(); + + } catch (\Exception $e) { + Log::error(sprintf('%s:Error with line [%s] (%s)',self::LOGKEY,$line,$e->getMessage()),['fields'=>$fields]); + DB::rollBack(); + throw new \Exception($e->getMessage()); + } // If our zone didnt exist, we'll create it with this system if (! $zo->exists) { @@ -365,6 +372,8 @@ class NodelistImport implements ShouldQueue } catch (\Exception $e) { Log::error(sprintf('%s:Error with line [%s] (%s)',self::LOGKEY,$line,$e->getMessage()),['fields'=>$fields]); + DB::rollBack(); + throw new \Exception($e->getMessage()); } if (! ($c % 100)) {