This commit is contained in:
Simon Pocrnjič 2025-12-17 20:51:31 +01:00
parent a4db37adfa
commit b8c9b51f29

View File

@ -217,7 +217,23 @@ public function process(Import $import, ?Authenticatable $user = null): array
if ($isPg) { if ($isPg) {
// Establish a savepoint so a failing row does not poison the whole transaction // Establish a savepoint so a failing row does not poison the whole transaction
try {
DB::statement('SAVEPOINT import_row_'.$rowNum); DB::statement('SAVEPOINT import_row_'.$rowNum);
} catch (\Throwable $se) {
ImportEvent::create([
'import_id' => $import->id,
'user_id' => $user?->getAuthIdentifier(),
'event' => 'savepoint_failed',
'level' => 'error',
'message' => 'Failed to create savepoint; transaction already aborted.',
'context' => [
'row_number' => $rowNum,
'exception' => $this->exceptionContext($se),
],
]);
throw $se; // abort import so root cause surfaces
}
} }
// Scope variables per row so they aren't reused after exception // Scope variables per row so they aren't reused after exception