Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[redis-messenger] remove undefined array key warnings#45619

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
nicolas-grekas merged 1 commit intosymfony:5.4fromPhilETaylor:patch-1
Mar 4, 2022

Conversation

@PhilETaylor
Copy link
Contributor

@PhilETaylorPhilETaylor commentedMar 2, 2022
edited
Loading

QA
Branch?5.4
Bug fix?yes
New feature?no
Deprecations?no
TicketsFix#45270
LicenseMIT

check that we actually have some information back from redis before assuming its an array with 2 keys to avoid undefined array key warnings as per#45270


so the code in question is this:

publicfunction get(): ?array    {if ($this->autoSetup) {$this->setup();        }$now =microtime();$now =substr($now,11).substr($now,2,3);$queuedMessageCount =$this->rawCommand('ZCOUNT',0,$now);while ($queuedMessageCount--) {if (![$queuedMessage,$expiry] =$this->rawCommand('ZPOPMIN',1)) {break;            }if (\strlen($expiry) ===\strlen($now) ?$expiry >$now :\strlen($expiry) <\strlen($now)) {// if a future-placed message is popped because of a race condition with// another running consumer, the message is readded to the queueif (!$this->rawCommand('ZADD','NX',$expiry,$queuedMessage)) {thrownewTransportException('Could not add a message to the redis stream.');                }break;            }$decodedQueuedMessage =json_decode($queuedMessage,true);$this->add(\array_key_exists('body',$decodedQueuedMessage) ?$decodedQueuedMessage['body'] :$queuedMessage,$decodedQueuedMessage['headers'] ?? [],0);        }

I think what's happening, as I often can have up to 1000 workers (yup, for real, making 1000 http requests to remote sites - see mySites.guru) I think the logic might be flawed.

Because, the following line gets the number of messages using ZCOUNT

$queuedMessageCount =$this->rawCommand('ZCOUNT',0,$now);

It will then enter a loop counting down that number of messages checking them

while ($queuedMessageCount--) {

At the same time, 999 other workers can be doing the same thing

it gets to a point where one of the workers doesnt get a message back fromZPOPMIN and thus we get undefined array keys...

You can see the result of ZPOPMIN is no longer an array once empty using the interactive test on the official redis page.

Screen Shot 2022-03-02 at 20 21 00

@carsonbot
Copy link

Hey!

Oh no, it looks like you have made this PR towards a branch that is not maintained anymore. :/
Could you update thePR base branch to target one of these branches instead? 4.4, 5.4, 6.0, 6.1.

Cheers!

Carsonbot

@PhilETaylorPhilETaylor changed the titleremove undefined array key warnings[redis-messenger] remove undefined array key warningsMar 2, 2022
@PhilETaylorPhilETaylor changed the base branch from5.3 to5.4March 2, 2022 20:17
@PhilETaylor
Copy link
ContributorAuthor

Rebased to 5.4

@carsonbot
Copy link

Hey!

I think@Steveb-p has recently worked with this code. Maybe they can help review this?

Cheers!

Carsonbot

@nicolas-grekasnicolas-grekas added this to the5.4 milestoneMar 4, 2022
@nicolas-grekas
Copy link
Member

Thank you@PhilETaylor.

@nicolas-grekasnicolas-grekas merged commite091d74 intosymfony:5.4Mar 4, 2022
This was referencedMar 5, 2022
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Projects

None yet

Milestone

5.4

Development

Successfully merging this pull request may close these issues.

3 participants

@PhilETaylor@carsonbot@nicolas-grekas

[8]ページ先頭

©2009-2025 Movatter.jp