Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore updating last_used_at for deciding the DB connection host #283

Merged
merged 10 commits into from
Jun 8, 2021

Conversation

alexjose
Copy link
Contributor

@alexjose alexjose commented Jun 8, 2021

Problem
Sanctum updates the access token's last_used_at property every time an API is authenticated using sanctum guard. This db query happens in the initial phase of the request cycle. This causes all the subsequent db queries to go to writer host even in the case of read operations.

Solution
Saving the updated last_used_at operation is moved to the application terminating event.

@alexjose alexjose changed the title moved the updating of last_used_at timestamp to terminating callback Updating of last_used_at timestamp moved to terminating callback Jun 8, 2021
@alexjose alexjose changed the title Updating of last_used_at timestamp moved to terminating callback Updating last_used_at timestamp moved to terminating callback Jun 8, 2021
@taylorotwell
Copy link
Member

Hmm - I think you have a good point but we need to solve it in a different way. We can't use the app function here. I will look into it.

@taylorotwell taylorotwell reopened this Jun 8, 2021
@taylorotwell
Copy link
Member

I have updated this PR - does it look OK to you?

@alexjose
Copy link
Contributor Author

alexjose commented Jun 8, 2021

Yes. This approach looks much better.

@alexjose alexjose changed the title Updating last_used_at timestamp moved to terminating callback Ignore Sanctum last_used_at updating for deciding the DB connection host Jun 8, 2021
@alexjose alexjose changed the title Ignore Sanctum last_used_at updating for deciding the DB connection host Ignore updating last_used_at for deciding the DB connection host Jun 8, 2021
@taylorotwell taylorotwell merged commit 64b30b4 into laravel:2.x Jun 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants