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

[Scheduler] Save checkpoint in a finally block #52307

Merged
merged 1 commit into from Oct 27, 2023

Conversation

FrancoisPog
Copy link
Contributor

@FrancoisPog FrancoisPog commented Oct 26, 2023

Q A
Branch? 6.3
Bug fix? yes
New feature? no
Deprecations? no
Issues Fix #52288
License MIT

As described in the linked issue :

The message generator appears to store stateful data by loading and saving the checkpoint with the cache.

But if the worker is configured to stop after X message(s), once the last message is handled, the (messenger) worker will break its loop and stop. In this case, the execution stop and the stateful data of the message (time of last execution for example) will not be saved.

So when the consumer restarts it will re-handle the message because the last execution was not stored.

So the solution here is to put the code that save the checkpoint in a finally block.
Thanks maelanleborgne.

@carsonbot
Copy link

Hey!

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

Symfony has a contribution guide which I suggest you to read.

In short:

  • Always add tests
  • Keep backward compatibility (see https://symfony.com/bc).
  • Bug fixes must be submitted against the lowest maintained branch where they apply (see https://symfony.com/releases)
  • Features and deprecations must be submitted against the 6.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

@FrancoisPog FrancoisPog changed the title Save checkpoint in a finally block [Scheduler] Save checkpoint in a finally block Oct 26, 2023
@stof
Copy link
Member

stof commented Oct 26, 2023

Please add a test preventing regressions.

@FrancoisPog FrancoisPog force-pushed the fix_52288 branch 2 times, most recently from e6148f1 to 1cc4165 Compare October 26, 2023 15:21
@fabpot
Copy link
Member

fabpot commented Oct 27, 2023

Thank you @FrancoisPog.

@fabpot fabpot merged commit 798a36a into symfony:6.3 Oct 27, 2023
6 of 9 checks passed
@Jeroeny
Copy link
Contributor

Jeroeny commented Oct 28, 2023

You might be interested to know that a checkpoint resets anyway after another process takes over: #52039

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants