Skip to content

feat: Improving reliability of future call execution using claim-based model - #4799

Merged
marcelomendoncasoares merged 48 commits into
serverpod:mainfrom
Crazelu:feat/reliable-future-call-execution
Mar 27, 2026
Merged

marcelomendoncasoares merged 48 commits into
serverpod:mainfrom
Crazelu:feat/reliable-future-call-execution

Conversation

@Crazelu

@Crazelu Crazelu commented Mar 5, 2026 •

Copy link
Copy Markdown
Collaborator

This PR introduces a claim-based model to improve the reliability of future call execution. It guarantees that future calls are executed at-least once even if server unexpectedly crashes just as a due future call is scheduled for execution.

Fixes 3417

Pre-launch Checklist

  • I read the Contribute page and followed the process outlined there for submitting PRs.
  • This update contains only one single feature or bug fix and nothing else. (If you are submitting multiple fixes, please make multiple PRs.)
  • I read and followed the Dart Style Guide and formatted the code with dart format.
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///), and made sure that the documentation follows the same style as other Serverpod documentation. I checked spelling and grammar.
  • I added new tests to check the change I am making.
  • All existing and new tests are passing.
  • Any breaking changes are documented below.

If you need help, consider asking for advice on the discussion board.

Breaking changes

None

@Crazelu Crazelu changed the title docs: Add design doc for improving reliability of future call execution feat: Improving reliability of future call execution using claim-based model Mar 6, 2026

@marcelomendoncasoares marcelomendoncasoares left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Great suggestion on the claim-based model. @Crazelu! I've put up a few topics for discussion to ensure the robustness of the solution.

Comment thread docs/design/reliable_future_calls.md Resolved
Comment thread docs/design/reliable_future_calls.md Resolved
Comment thread docs/design/reliable_future_calls.md Resolved
Comment thread docs/design/reliable_future_calls.md Resolved
Comment thread docs/design/reliable_future_calls.md Resolved
Comment thread docs/design/reliable_future_calls.md Resolved
@Crazelu
Crazelu force-pushed the feat/reliable-future-call-execution branch from 1f2f947 to 1ec203a Compare March 20, 2026 14:02
@Crazelu
Crazelu marked this pull request as ready for review March 20, 2026 14:20
Crazelu added 26 commits March 23, 2026 08:36
@Crazelu
Crazelu force-pushed the feat/reliable-future-call-execution branch from 844bc6a to 61b8c7f Compare March 23, 2026 07:36

@marcelomendoncasoares marcelomendoncasoares left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nice implementation! A few suggestions for improvement/discussion and then I'll jump for a more detailed review on the tests.

@marcelomendoncasoares marcelomendoncasoares left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Great work with the implementation, @Crazelu! A few topics for discussion/improvement on the implementation and to prevent future flakiness on tests. The test coverage is great, with only two cases that I would suggest adding.

Crazelu added 2 commits March 25, 2026 12:26
…d eagerly return from a future call run when a claim is not acquired

@marcelomendoncasoares marcelomendoncasoares left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Think we're very close now! Only a few small suggestions after the last review.

One last test that I realized we're missing is for reclaimed future calls from the perspective of a recovering server - server A lost the claim but recovered and tried to update the heartbeat after server B already reclaimed it. We test that server B manages to replace a stale lock, but we should also assert that server A aborts the run and does not mess with server B claim. Such test will require two concurrent managers to simulate real world concurrency.

@marcelomendoncasoares marcelomendoncasoares left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM! 🚀

Great work, @Crazelu!

@marcelomendoncasoares marcelomendoncasoares left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

A few comments on the changes and suggestion to improve the last integration test.

@marcelomendoncasoares
marcelomendoncasoares merged commit f5b9b0b into serverpod:main Mar 27, 2026
151 of 152 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Mar 27, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Future calls are lost if server shuts down during execution

2 participants