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

[5.4] Queue prefix added twice with beanstalk #18978

Closed
it-can opened this issue Apr 28, 2017 · 13 comments
Closed

[5.4] Queue prefix added twice with beanstalk #18978

it-can opened this issue Apr 28, 2017 · 13 comments
Labels

Comments

@it-can
Copy link
Contributor

it-can commented Apr 28, 2017

  • Laravel Version: 5.4.20
  • PHP Version: 7.1.4
  • Database Driver & Version: MariaDB

Description:

In Laravel 5.4.20 there is a queue prefix added (#18860). But when I started adding a prefix it seems to be added twice in my beanstalk tube. I did not check of this happens with other queue drivers... I tested this with multiple laravel apps on multiple servers... The queue works fine without a prefix, but does not work when using a prefix...

without prefix:

portal

with prefix "server1"

server1server1portal

Steps To Reproduce:

Add queue prefix and list your beanstalk tubes

telnet 127.0.0.1 11300

list-tubes
@laurencei
Copy link
Contributor

I cant replicate? I get server1portal

Can you post your full queue config?

@it-can
Copy link
Contributor Author

it-can commented Apr 28, 2017

config/queue.php

<?php

return [

    /*
    |--------------------------------------------------------------------------
    | Default Queue Driver
    |--------------------------------------------------------------------------
    |
    | The Laravel queue API supports a variety of back-ends via an unified
    | API, giving you convenient access to each back-end using the same
    | syntax for each one. Here you may set the default queue driver.
    |
    | Supported: "sync", "database", "beanstalkd", "sqs", "redis", "null"
    |
    */

    'default' => env('QUEUE_DRIVER', 'sync'),

    /*
    |--------------------------------------------------------------------------
    | Queue Prefix
    |--------------------------------------------------------------------------
    |
    | If you are running multiple sites on a single server, you may experience
    | crosstalk among sites if they use the same name for queue tubes. This
    | optional value defines a prefix that will automatically be applied
    | to queue tubes as a way to prevent this crosstalk.
    |
    */
    'prefix'  => env('QUEUE_PREFIX', ''),

    /*
    |--------------------------------------------------------------------------
    | Queue Connections
    |--------------------------------------------------------------------------
    |
    | Here you may configure the connection information for each server that
    | is used by your application. A default configuration has been added
    | for each back-end shipped with Laravel. You are free to add more.
    |
    */

    'connections' => [

        'sync' => [
            'driver' => 'sync',
        ],

        'database' => [
            'driver'      => 'database',
            'table'       => 'jobs',
            'queue'       => env('QUEUE_NAME', 'default'),
            'retry_after' => 90,
        ],

        'beanstalkd' => [
            'driver'      => 'beanstalkd',
            'host'        => 'localhost',
            'queue'       => env('QUEUE_NAME', 'default'),
            'retry_after' => 90,
        ],

        'sqs' => [
            'driver' => 'sqs',
            'key'    => 'your-public-key',
            'secret' => 'your-secret-key',
            'prefix' => 'https://sqs.us-east-1.amazonaws.com/your-account-id',
            'queue'  => env('QUEUE_NAME', 'default'),
            'region' => 'us-east-1',
        ],

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

    ],

    /*
    |--------------------------------------------------------------------------
    | Failed Queue Jobs
    |--------------------------------------------------------------------------
    |
    | These options configure the behavior of failed queue job logging so you
    | can control which database and table are used to store the jobs that
    | have failed. You may change them to any database / table you wish.
    |
    */

    'failed' => [
        'database' => env('DB_CONNECTION', 'mysql'),
        'table'    => 'failed_jobs',
    ],

];

in my .env file I set this:

QUEUE_DRIVER=beanstalkd
QUEUE_NAME=portal
QUEUE_PREFIX=server1

@laurencei
Copy link
Contributor

well - that is sync and not beanstalkd?

@it-can
Copy link
Contributor Author

it-can commented Apr 28, 2017

@laurencei typo...

@laurencei
Copy link
Contributor

laurencei commented Apr 28, 2017

ok - well I've got something similar and I dont see that.

however I think I found another bug relating to queue prefixes and "default" connections - so I'm looking into it now. It might be related - dunno...

@it-can
Copy link
Contributor Author

it-can commented Apr 28, 2017

@laurencei can you share some info on the possible "bug"?

@laurencei
Copy link
Contributor

laurencei commented Apr 28, 2017

I'm able to replicate a prexfixprefixqueue with the database driver when running queue:work

I'm looking into it now and will do a PR - give me 30mins...

I'll check if affects other drivers once I worked out the exact source... nearly there...

@laurencei
Copy link
Contributor

@it-can - I'm about to submit a PR.

I'm fairly sure it relates to your issue, because the worker will duplicate prefixes. My guess is when Beanstalkd is trying to access a non-existent queue it probably creates it first.

@it-can
Copy link
Contributor Author

it-can commented Apr 28, 2017

Nice sounds like it...

@laurencei
Copy link
Contributor

@it-can - can you please test against the master branch. Taylor just merged my PR.

You might need to "flush" your beanstalkd tubes to remove the old double-prefixed from showing - then try again?

@themsaid
Copy link
Member

themsaid commented Apr 28, 2017

Thank you @laurencei for the fix, I guess you meant to test against the 5.4 branch not master.

@laurencei
Copy link
Contributor

laurencei commented Apr 28, 2017

Yeah - sorry - I meant the latest dev version of the 5.4 branch (since the fix is not yet tagged I dont think?)

@themsaid themsaid added the bug label Apr 28, 2017
@it-can
Copy link
Contributor Author

it-can commented Apr 28, 2017

This fix works for my case 👍 Thanks

@it-can it-can closed this as completed Apr 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants