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

[Bug Report] QueueTimeoutAnalyzer does not understand which queue is used on horizon #94

Open
potsky opened this issue Jan 21, 2022 · 2 comments
Labels
enhancement New feature or request

Comments

@potsky
Copy link

potsky commented Jan 21, 2022

Versions

  • PHP version: 8.0.*
  • Laravel version: 5.8.0.0
  • Enlightn version:
  • Enlightn Pro version (if applicable): 1.16.0

Description

I have just installed MailCoach from Spatie and I have this error when running enlightn:

Check 66/110: An appropriate timeout and retry after is set for queues. Failed
The queue timeout value must be at least several seconds shorter than the retry after configuration value. Your mailcoach-redis queue connection's retry after value is set at 660 seconds while your timeout value is set at 3600 seconds. This can cause problems such as your jobs may be processed twice or the queue worker may crash.
At config/queue.php: line(s): 64.
Documentation URL: https://www.laravel-enl

So is a very good point, I have alerted Spatie about their default configuration https://github.com/spatie/laravel-mailcoach/discussions/853

But if I set the timeout to 11 * 60 -3, I have now a new error :

The queue timeout value must be at least several seconds shorter than the retry after configuration value. Your redis queue connection's retry after value is set at 90 seconds while your timeout value is set at 657 seconds. This can cause problems such as your jobs may be processed twice or the queue worker may crash.
At config/queue.php, line 64.

I think the 90 comes from the default redis connection retry after parameter which is not used at all in horizon defaults array in mailcoach supervisors.

Steps to Reproduce

Use this horizon configuration:

    'defaults' => [
        'supervisor-default' => [
            'connection' => 'redis',
            'queue' => ['default'],
            'balance' => 'simple',
            'memory' => 100,
            'tries' => 3,
            'nice' => 0,
        ],
        'supervisor-browser' => [
            'connection' => 'redis',
            'queue' => ['browser'],
            'balance' => 'simple',
            'memory' => 192,
            'tries' => 3,
            'nice' => 0,
        ],
        'mailcoach-general' => [
            'connection' => 'mailcoach-redis',
            'queue' => ['mailcoach', 'mailcoach-feedback', 'send-mail', 'send-automation-mail'],
            'balance' => 'auto',
            'memory' => 100,
            'processes' => 10,
            'tries' => 2,
            'timeout' => 11 * 60 - 3,
        ],
        'mailcoach-heavy' => [
            'connection' => 'mailcoach-redis',
            'queue' => ['send-campaign'],
            'balance' => 'auto',
            'memory' => 100,
            'processes' => 3,
            'tries' => 1,
            'timeout' => 11 * 60 - 3,
        ],
    ],

    'environments' => [
        'production' => [
        ],

        'staging' => [
        ],

        'local' => [
        ],

        'CI' => [
        ],
    ],

and use this queue configuration:

    'connections' => [
        'sync' => [
            'driver' => 'sync',
        ],
...
        'mailcoach-redis' => [
            'driver' => 'redis',
            'connection' => 'mailcoach',
            'queue' => 'mailcoach',
            'retry_after' => 11 * 60,
            'block_for' => null,
        ],

        'redis' => [
            'driver' => 'redis',
            'connection' => 'default',
            'queue' => env('REDIS_QUEUE', 'default'),
            'retry_after' => 90,
            'block_for' => null,
        ],
    ],

Expected behavior:

Test pass

Actual behavior:

Test does not pass because I cannot see in src/Analyzers/Reliability/QueueTimeoutAnalyzer.php in method getTimeoutAndRetryAfter(array $config) a mapping between superivisor and connections.

It only get all supervisors and all connections:

            data_get(config('horizon.defaults', []), '*.timeout'),

Additional Information

I have disable this check for the moment but it is a very good check I would like to keep running ;-)

@paras-malhotra paras-malhotra added the enhancement New feature or request label Feb 21, 2022
@paras-malhotra
Copy link
Member

Thanks for reporting this. I'll look into it and also welcome any PRs to fix this if anyone's interested.

@LocalHeroPro
Copy link

Same here.
I have two connections, short one - 960' - and long one - 18060'. Settings in queue.php file.
And in horizon.php file I have two supervisors specified by connection -short, long - and that supervisors have timeout set one minute less that retry_after in queue.php file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants