php - Laravel 5.2 job jammed in database? -
i using laravel queues jobs insert large excel in database , jobs getting jammed , not executing.
i chunk file contents(250 rows per job) , inserts of them until stops.
insert code (job inserts 250 or less rows)
public function handle() { $uuid = uuid::generate(4); $defaultssize = 0; $customsize = 0; $defaultsidfields = []; $customfields = []; if (sizeof($this->matrixdefaultfields) > 0) { $defaultssize = sizeof($this->matrixdefaultfields[0][0]); //size of 1 of vecs in default values $defaultsidfields = $this->matrixdefaultfields[0][0]; // default fields id } if (sizeof($this->matrixcustomfields) > 0) { $customsize = sizeof($this->matrixcustomfields[0][0]); //sizeof 1 of vecs in custom values $customfields = $this->matrixcustomfields[0][0]; // custom fields id } ($i = 0; $i < sizeof($this->matrixcontacts); $i++) { $contact = contact::create(['uuid' => $uuid, 'id_contact_list' => $this->matrixcontacts[$i][1], 'nome' => $this->matrixcontacts[$i][2], 'email' => $this->matrixcontacts[$i][3], 'unsub_code' => $this->matrixcontacts[$i][4]]); ($j = 0; $j < $defaultssize; $j++) { $defaultsvaluesfields = $this->matrixdefaultfields[$i][1]; //field value companylistfieldvalues::create(['company_id' => $this->idcompany, 'contact_id' => $contact->id, 'field_id' => $defaultsidfields[$j], 'isdefault' => 1, 'value' => $defaultsvaluesfields[$j]]); } ($k = 0; $k < $customsize; $k++) { $customvaluesfields = $this->matrixcustomfields[$i][1]; //field value companylistfieldvalues::create(['company_id' => $this->idcompany, 'contact_id' => $contact->id, 'field_id' => $customfields[$k], 'isdefault' => 0, 'value' => $customvaluesfields[$j]]); } } }
code generator of jobs(this 1 works fine)
($row = $this->startfrom; $row <= $highestrow; $row++) { if ($rowmatrix == $chunksize) { // $job = (new importexcelinsert($matrixcontacts, $matrixdefaultfields, $matrixcustomfields, $this->idcompany))->delay($jobdelay)->onqueue('excelinserts'); // var_dump($matrixcontacts); $job = (new importexcelinsert($matrixcontacts, $matrixdefaultfields, $matrixcustomfields, $this->idcompany, $rowmatrix))->delay($jobdelay)->onqueue('excelinserts'); $this->dispatch($job); $njobs++; $matrixcontacts = []; $matrixdefaultfields = []; $matrixcustomfields = []; $rowmatrix = 0; } $useremail = $sheet->getcellbycolumnandrow($posemail, $row)->getvalue(); if ($useremail == '' || !filter_var($useremail, filter_validate_email)) { $error++; } else if (contact::where('email', '=', $useremail)->where('id_contact_list', '=', $this->idlist)->count()) { $ignored++; } else { // $uuid = uuid::generate(4); $matrixcontacts[$rowmatrix][1] = $this->idlist; //contact_list_id $matrixcontacts[$rowmatrix][2] = $sheet->getcellbycolumnandrow($posnome, $row)->getvalue(); //name $matrixcontacts[$rowmatrix][3] = $useremail; //email $matrixcontacts[$rowmatrix][4] = $unsubcode; //unsubscribe code $vecfieldid = []; $vecvalues = []; $i = 0; if (!$this->arraydefaultfields[0] == null) { ($j = 0; $j < sizeof($this->arraydefaultfields); $j += 2) { $vecfieldid[$i] = $this->arraydefaultfields[$j]; $vecvalues[$i] = $sheet->getcellbycolumnandrow($this->arraydefaultfields[$j + 1], $row)->getvalue(); $i++; } $matrixdefaultfields[$rowmatrix][0] = $vecfieldid; $matrixdefaultfields[$rowmatrix][1] = $vecvalues; } $i = 0; if (!$this->arraycustomfields[0] == null) { ($j = 0; $j < sizeof($this->arraycustomfields); $j += 2) { $vecfieldid[$i] = $this->arraycustomfields[$j]; $vecvalues[$i] = $sheet->getcellbycolumnandrow($this->arraycustomfields[$j + 1], $row)->getvalue(); $i++; } $matrixcustomfields[$rowmatrix][0] = $vecfieldid; $matrixcustomfields[$rowmatrix][1] = $vecvalues; } $rowmatrix++; } } if (!empty($matrixcontacts)) { $job = (new importexcelinsert($matrixcontacts, $matrixdefaultfields, $matrixcustomfields, $this->idcompany, $rowmatrix + 1))->delay($jobdelay)->onqueue('excelinserts'); $this->dispatch($job); $njobs++; }
edit - print screen of database
change driver 'sync' see errors in job. way, can discard problems in code or see happen