Skip to content
This repository has been archived by the owner on May 31, 2022. It is now read-only.

[🐛 BUG]: Infinity loop after receiving a bad response #190

Closed
1 task done
sergey-telpuk opened this issue Jan 5, 2022 · 0 comments · Fixed by #198
Closed
1 task done

[🐛 BUG]: Infinity loop after receiving a bad response #190

sergey-telpuk opened this issue Jan 5, 2022 · 0 comments · Fixed by #198
Assignees
Labels
B-bug Bug: bug, exception F-need-verification
Milestone

Comments

@sergey-telpuk
Copy link

No duplicates 🥲.

  • I have searched for a similar issue in our bug tracker and didn't find any solutions.

What happened?

There is the loop for handling the received task.

 while ($task = $this->consumer->waitTask()) {
 
            try {
                $this->logger->debug('Processing task');

                $this->eventHandler->handle($task->getPayload()); <----// HERE can be a logical error 

                /* @var ReceivedTaskInterface */
                $task->complete();
            } catch (Throwable $throwable) { <--- // CATCH this logical error here and try to attempt again, when
                // attemps are over, our loop procceeds working like infitity mode, 
                // and 
               // we see in console the error bellow
                                                                                             
                $this->logger->warning('Got exception on job handling: ' . $throwable->getMessage(), $throwable->getTrace());

                $retries = max(
                    (int) $task->getHeaderLine('attempts') - 1,
                    0
                );

                if (0 == $retries || !$this->shouldBeRestarted) {
                    try {
                        $task->fail($throwable, false);
                    } catch (Exception) {
                        $this->logger->alert($throwable->getMessage());
                    }

                    $this->logger->warning('Failed to complete task');
                } else {
                    $this->logger->info('Restarting failed task, retries left: ' . $retries);

                    try {
                        /**
                         * @psalm-suppress ArgumentTypeCoercion
                         */
                        $task->withHeader('attempts', (string) $retries)
                            ->withDelay($this->resendDelaySeconds)
                            ->fail($throwable, true);
                    } catch (Exception) {
                        $this->logger->alert($throwable->getMessage());
                    }
                }
            }
        }

Version

v2.6.6

Relevant log output

{"level":"ERROR","ts":"2022-01-05T13:26:31.915Z","logger":"jobs        ","msg":"job negatively acknowledged","error":"jobs_handle_response: protocol.errorResp.Headers: ReadMapCB: expect { or n, but found [, error found in #10 byte of ...|headers\":[]}|..., bigger context ...|in}\",\"requeue\":false,\"delay_seconds\":0,\"headers\":[]}|..."}
@rustatian rustatian moved this to Backlog in RoadRunner Jan 5, 2022
@rustatian rustatian moved this from Backlog to Todo in RoadRunner Jan 5, 2022
@rustatian rustatian added this to the v2.7.0 milestone Jan 5, 2022
@rustatian rustatian moved this from Todo to InProgress in RoadRunner Jan 10, 2022
@rustatian rustatian changed the title [🐛 BUG]: Infinity loop after [🐛 BUG]: Infinity loop after receiving a bad response Jan 10, 2022
Repository owner moved this from InProgress to Done in RoadRunner Jan 10, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
B-bug Bug: bug, exception F-need-verification
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants