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

[Messenger] Second batch handler worker returns "The acknowledger was not called by the ... batch handler."#58433

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

Open
ehoutsma wants to merge2 commits intosymfony:6.4
base:6.4
Choose a base branch
Loading
fromehoutsma:second-batch-handler-worker

Conversation

ehoutsma
Copy link

QA
Branch?6.4
Bug fix?yes
New feature?no
Deprecations?no
IssuesFix #...
LicenseMIT

When using multiple Batch handlers, the situation can occur that there are multiple batch handlers that have messages that aren't processed and therefor not acked yet. The issue is caused by a optimalization that unsets the current batch handler in a foreach loop.

"The acknowledger was not called by the ... batch handler." is thrown when a worker is stopped and the batch isn't handled.

The issue is reproducable and testable with the attached unit test.

@carsonbot
Copy link

Hey!

I see that this is your first PR. That is great! Welcome!

Symfony has acontribution guide which I suggest you to read.

In short:

  • Always add tests
  • Keep backward compatibility (seehttps://symfony.com/bc).
  • Bug fixes must be submitted against the lowest maintained branch where they apply (seehttps://symfony.com/releases)
  • Features and deprecations must be submitted against the 7.2 branch.

Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change.

When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor!
If this PR is merged in a lower version branch, it will be merged up to all maintained branches within a few days.

I am going to sit back now and wait for the reviews.

Cheers!

Carsonbot

@carsonbotcarsonbot changed the titleBug: Second batch handler worker returns "The acknowledger was not called by the ... batch handler."[Messenger] Bug: Second batch handler worker returns "The acknowledger was not called by the ... batch handler."Oct 2, 2024
@OskarStarkOskarStark changed the title[Messenger] Bug: Second batch handler worker returns "The acknowledger was not called by the ... batch handler."[Messenger] Second batch handler worker returns "The acknowledger was not called by the ... batch handler."Oct 2, 2024
} catch (\Throwable $e) {
$this->acks[] = [$transportName, $envelope, $e];
}
$unacks->next();
$unacks->detach($batchHandler);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This means that we now don't call the destructor of the $batchHandler (if any) inside the try/catch.
Is that the fix or a regression?

Copy link
Author

@ehoutsmaehoutsmaOct 3, 2024
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Thank you for your review.

The fix is that we unset the batchHandler after we set the iterator to the next batchHandler. Before it would unset the current batchHandler, and then tries to proceed to the next batchHandler but can't find the current index because it was unset.

See this comment:https://www.php.net/manual/en/splobjectstorage.detach.php#97644

Catching a Throwable of the unset, has nothing to do with the handling of the batch.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

@nicolas-grekas Do you have enough information to accept this PR or do you need more information. It would help us a lot if this bug is fixed.

rairlie, pmishev, and KirosML reacted with thumbs up emoji
@rairlie
Copy link

I've also encountered this issue, and use a similar fix locally.

As@ehoutsma says, the problem is simply that$unacks is modified within the loop, messing up the iteration:

foreach ($unacksas$batchHandler) {...try {...unset($unacks[$batchHandler],$batchHandler);// <<-- $unacks modified while being iterated    }catch (\Throwable$e) {...    }}

Working example:

$handler1 =newstdClass();$handler1->val =1;$handler2 =newstdClass();$handler2->val =2;$unacks =newSplObjectStorage();$unacks->attach($handler1);$unacks->attach($handler2);foreach ($unacksas$handler) {var_dump($handler);    unset($unacks[$handler]);}

Results in only one handler being processed:

object(stdClass)#1 (1) {  ["val"]=>  int(1)}

@ehoutsma
Copy link
Author

I understand this issue doesn't occur with a lot of users. Leaving this issue unsolved, makes the use of batchhandling with multiple batchhandlers on the same queue unreliable.

@nicolas-grekas, Is it possible to merge this issue, since this is an issue that is still available even in version 7 of symfony?

rairlietds, mrbellek, lermontex, ronaldvandenbrink123inkt, and pmishev reacted with thumbs up emoji

@ehoutsmaehoutsma marked this pull request as draftJune 12, 2025 06:38
@ehoutsmaehoutsma marked this pull request as ready for reviewJune 12, 2025 06:39
@carsonbot
Copy link

Hey!

I see that this is your first PR. That is great! Welcome!

Symfony has acontribution guide which I suggest you to read.

In short:

  • Always add tests
  • Keep backward compatibility (seehttps://symfony.com/bc).
  • Bug fixes must be submitted against the lowest maintained branch where they apply (seehttps://symfony.com/releases)
  • Features and deprecations must be submitted against the 7.4 branch.

Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change.

When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor!
If this PR is merged in a lower version branch, it will be merged up to all maintained branches within a few days.

I am going to sit back now and wait for the reviews.

Cheers!

Carsonbot

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@nicolas-grekasnicolas-grekasAwaiting requested review from nicolas-grekas

Assignees
No one assigned
Projects
None yet
Milestone
6.4
Development

Successfully merging this pull request may close these issues.

5 participants
@ehoutsma@carsonbot@rairlie@nicolas-grekas@OskarStark

[8]ページ先頭

©2009-2025 Movatter.jp