7 months ago

Job release and duplicate entries during model update

Posted 7 months ago by lambooni

I have a strange issue related to releasing jobs and model update throwing duplicate entry errors. If I run the code with the release in, I get the error. Remove the release from the job and all runs fine.

My job is as follows:

    public function handle(LinnworksService $linnworksService)
        } catch(\Exception $e){

Generally a fail on the job happens due to an API connection error within the Linnworks API (throttle, server down etc.)

The script which fails creates the duplicate entry error (simplified):

$model = Model::where('source_id', $source_id)->where('source', $source)->first();
if(isset($model)) $model->update($data);

The very strange thing is that the duplicate entry is on the keys for which I am searching for table_source_id_source_unique;

As I say, I have fixed this by removing the release but I am curious as to why this may be occurring.

Please sign in or create an account to participate in this conversation.