mirror of
https://github.com/Bubka/2FAuth.git
synced 2025-06-11 07:26:41 +02:00
Set multiple retries with lighter lock & Send 409 in case of deadlock
This commit is contained in:
parent
19f3a71c03
commit
c8b5bd32a6
@ -107,6 +107,8 @@ class GroupController extends Controller
|
||||
$group->loadCount('twofaccounts');
|
||||
} catch (ModelNotFoundException $exc) {
|
||||
abort(404);
|
||||
} catch (\Throwable $th) {
|
||||
abort(409, 'Conflict');
|
||||
}
|
||||
|
||||
return new GroupResource($group);
|
||||
|
@ -59,7 +59,7 @@ class GroupService
|
||||
$ids = is_array($ids) ? $ids : [$ids];
|
||||
|
||||
DB::transaction(function () use ($group, $ids, $user) {
|
||||
$group = Group::lockForUpdate()->find($group->id);
|
||||
$group = Group::sharedLock()->find($group->id);
|
||||
$twofaccounts = TwoFAccount::sharedLock()->find($ids);
|
||||
|
||||
if (! $group) {
|
||||
@ -73,7 +73,7 @@ class GroupService
|
||||
$group->twofaccounts()->saveMany($twofaccounts);
|
||||
|
||||
Log::info(sprintf('Twofaccounts #%s assigned to group %s (ID #%s)', implode(',', $ids), var_export($group->name, true), $group->id));
|
||||
});
|
||||
}, 5);
|
||||
} else {
|
||||
Log::info('Cannot find a group to assign the TwoFAccounts to');
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user