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

Updated stamp creation to leverage the retry helper method #25

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

qschmick
Copy link
Contributor

Issue

When multiple requests happen (AJAX Async processing) and they will all have the same process hash the first request will work, some subset of following requests will fail, then the rest will work. This happens because if the hash doesn't already exist we block via a cache lock. This then returns a null instance for the subsequent requests until the record is created.

Solution

Updated the firstOrCreate method to use the retry helper. Now when a null instance would be returned instead we'll throw an exception and retry both finding the instances in the DB and checking on the Cache::lock.

I tried to set sane starting values (25ms sleep and 4 total retries) which should be well enough for most instances to create a single DB records (100ms total)

Release notes

Better handling of stamp creation to support high concurrency

@qschmick
Copy link
Contributor Author

@tomschlick If you get a chance

@tomschlick
Copy link
Contributor

@qschmick I no longer have write access to this repo and I think the last remaining people do did have also left the org. I have forked it here: https://github.com/tomschlick/laravel-process-stamps if you want to re-point your PR to that version.

@paulrrogers
Copy link
Contributor

@solflare I think this would help with some of the races we saw at PS. Maybe you can get it into this upstream release?

@qschmick
Copy link
Contributor Author

@paulrrogers Just FYI, @tomschlick and I are working for Fork these and continue open source support of them under the org https://github.com/always-open. I've already sent you an invite.

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.

3 participants