Skip to content

Commit

Permalink
remove database transaction that could cause lockups (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Schlick committed Jun 2, 2020
1 parent 8c9af8d commit b600404
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/ProcessStamp.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,11 @@ public static function firstOrCreateByProcess(array $process, ?string $hash = nu
$parent = static::firstOrCreateByProcess(static::getProcessName($process['type'], $process['parent_name']));
}

return DB::transaction(function () use ($hash, $process, $parent) {
return static::lockForUpdate()->firstOrCreate(['hash' => $hash], [
'name' => trim($process['name']),
'type' => $process['type'],
'parent_id' => optional($parent)->getKey(),
]);
}, 5);
return static::lockForUpdate()->firstOrCreate(['hash' => $hash], [
'name' => trim($process['name']),
'type' => $process['type'],
'parent_id' => optional($parent)->getKey(),
]);
}

/**
Expand Down

0 comments on commit b600404

Please sign in to comment.