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

queue:work stopping on failure #35321

Closed
Adizbek opened this issue Nov 22, 2020 · 3 comments
Closed

queue:work stopping on failure #35321

Adizbek opened this issue Nov 22, 2020 · 3 comments

Comments

@Adizbek
Copy link

Adizbek commented Nov 22, 2020

  • Laravel Version: 7.28.4
  • PHP Version: 7.4.11
  • Database Driver & Version: mysql

Description:

php artisan queue:work stopping after Http client throws exception, as I investigated, causedByLostConnection is getting true, but actually queue driver connection has not lost connection, http client couldn't connect. So, I caught error in job and rethrow it with different signature and now queue:work is continuing working

Steps To Reproduce:

Just create a simple job, connect to port which is not serving anything with http client, try with this code, it should fail and exit, and then uncomment commented codes, worker should work as expected without exiting.

    public function handle()
    {
//        try {
            $response = Http::post($this->callback_url, [
                'id' => $this->id,
                'result' => $this->result
            ]);

            if ($response->successful()) {
                $this->entity->update(['delivered' => 1]);
            }
//        } catch (\Exception $e) {
//            throw new \Exception("Server has not returned successful response code");
//        }
    }

Additional information:

Exception message is

 cURL error 7: Failed to connect to localhost port 5000: Connection refused 

I think this is causing problem.

@paras-malhotra
Copy link
Contributor

paras-malhotra commented Nov 22, 2020

Hmm looks like a genuine bug. It was intended to prevent DB disconnects on DB driver queue workers but apparently the curl error returns the same string that's used to detect DB lost connections. This line is causing the worker to stop:

$this->stopWorkerIfLostConnection($e);

@paras-malhotra
Copy link
Contributor

Submitted a PR (#35323) to fix this

@taylorotwell
Copy link
Member

PR merged.

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

No branches or pull requests

3 participants