Support the ongoing development of Laravel.io →
Database Eloquent
Last updated 2 years ago.
0

I've successfully resolved this by wrapping the pair of queries in a transaction. Not as optimal as I had hoped, but at least it has appeared to stop the race condition. It does appear to have increased my server load a bit, but I'm still investigating whether it was this or something else.

0

Just as a follow-up, using this method I am now getting deadlocks, so it did not solve the issue.

0

I have created a package that gives a trait you can apply to your models and have REPLACE and INSERT IGNORE queries. It's really just a macro but it saves the challenge of having to build a raw query and its bindings every time you need it.

https://packagist.org/packages/jdavidbakr/replaceable-model

0

Sign in to participate in this thread!

Eventy

Your banner here too?

jdavidbakr jdavidbakr Joined 28 Jul 2015

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.