-
-
Notifications
You must be signed in to change notification settings - Fork 135
Fix verification attempts not transactional #2549
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
Conversation
69944ce to
1313640
Compare
|
it might be more concise to replace the select with an |
1313640 to
c32298f
Compare
|
We might be able to simplify it even more such that only one update (with nested select) and one (conditional) delete is required, see c32298f Will test more tomorrow, too tired to trust my Q&A rn |
c32298f to
df129b1
Compare
|
Q&A of df129b1: 2025-09-19.07-16-20.mp4I also noticed that we have >9000 rows in our I think we should also only fetch verification requests that haven't expired. Our mail mentions it expires in 5 minutes, but the code doesn't care about that. |
|
My code will also leave expired verification requests around but imo, this should be handled in another PR. Next to #2514, I'd also like to improve the UX if a wrong code was entered because it redirects to a 'try again' page and then you get redirected back if you click it. Ideally we would show the error like a form validation error (but obviously can't validate it on the client). @Soxasora, in case you feel bad because I have so many suggestions regarding your code, don't, since it's been 7 months, the code has been working well, and it's all just minor stuff that I'm sure you would handle a lot better if you would write this code today. It's completely normal to look back at code and be like "wow, I could have done this a lot better." haha |
|
No worries, I didn't feel that way. That code comes from a time in which I was getting to know Prisma better and naively wanted to avoid at all costs pure queries, with all the drawbacks from it. This is what it should've been. Great improvement!
I contemplated a weekly job for this, to be honest we have lots of places where we never do cleanups. But I did add a midnight cleanup job to comments view tracking just because that could become really big day after day.
Would be amazing! I didn't consider extra UX while doing that PR as people couldn't access SN via PWA |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It works correctly! Without any problems. But I left a comment because I'm scratching my head over what seems a double lock?
|
We need to lock on select so other tx also block on select, not after we already updated the value. At least this is my understanding. I also can't only use UPDATE because I want to update the most recent row and UPDATE can't sort rows before updating will reply to the other stuff later |
I imagine this to work similar like the checks for selecting a territory. They run GraphQL queries for validation. Lines 169 to 187 in 21b4c4b
|
Description
related to #1818 (comment):
This uses
SELECT FOR UPDATEwith$queryRawto make sure other tx will wait before reading the attempt count if there's already one tx in progress.Video
2025-09-19.07-16-20.mp4
Checklist
Are your changes backward compatible? Please answer below:
yes
On a scale of 1-10 how well and how have you QA'd this change and any features it might affect? Please answer below:
8, see videoFor frontend changes: Tested on mobile, light and dark mode? Please answer below:
n/a
Did you introduce any new environment variables? If so, call them out explicitly here:
no
Did you use AI for this? If so, how much did it assist you?
no