-
Notifications
You must be signed in to change notification settings - Fork 318
Closed
Description
Due to a high concurrency on my company's API, Sanctum leads to deadlocks.
This line of code, which updating last_login_at is responsible for these deadlocks.
Line 73 in f30df69
| tap($accessToken->forceFill(['last_used_at' => now()]))->save() |
My company doesn't need this last_login_at column, and I can see that Sanctum doesn't use it anywhere.
It seems like an optional column. I guess it exists just for those who'd like to display it to the users or to make some logic above it.
I think Sanctum should provide the ability to choose whether this column is "working" or not. It should be configurable in my opinion.
What do you think guys?
As a workaround, I've used an observer with a return false to cancel this update query.
<?php
namespace App\Observers;
use Laravel\Sanctum\PersonalAccessToken;
class PersonalAccessTokenObserver
{
public function updating(PersonalAccessToken $accessToken)
{
$dirtyAttributes = array_keys($accessToken->getDirty());
if (count($dirtyAttributes) === 1 && $dirtyAttributes[0] === 'last_used_at') {
return false;
}
}
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels