8000 Do not run multiple child strands inside donate by jeremyevans · Pull Request #3493 · ubicloud/ubicloud · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Do not run multiple child strands inside donate #3493

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jeremyevans
Copy link
Contributor
@jeremyevans jeremyevans commented Jun 23, 2025

Running multiple child strands inside donate can lead to a situation where one or more child progs successfully complete, and a later child prog fails, and the failure of the later child prog rolls back the database changes made by the child progs that successfully complete. If the child progs are not idempotent, this results in a situation that cannot be fixed without manual intervention.

Instead, as soon as a child is successfully run inside donate, nap for 0 seconds. That will mean the remaining child strands are skipped during that donate method. The Nap flow control exception will be caught inside Strand#unsynchronized_run. The parent will update it's own schedule, and the transaction will commit. Strand#run will handle the Nap 0 exception and if the deadline hasn't passed, it will immediately rerun the strand. Assuming the strand still has child processes to run, that will likely get back to the donate call, where the next child strand will run, repeating this process until the deadline has passed, all child strands have run, or there is an error running a child strand.


Important

Modify donate in prog/base.rb to nap after each successful child run, preventing rollback of successful transactions if a later child fails, and add corresponding tests.

  • Behavior:
    • Modify donate in prog/base.rb to nap for 0 seconds after each successful child strand run, preventing rollback of successful transactions if a later child fails.
    • Introduce failer method in prog/test.rb to simulate failure in child strands.
  • Tests:
    • Add test in base_spec.rb to ensure failure of one child strand does not affect others in donate method.
  • Misc:
    • Minor changes in prog/test.rb to support new test scenarios.

This description was created by Ellipsis for 1b771a1. You can customize this summary. It will automatically update as commits are pushed.

Running multiple child strands inside donate can lead to a situation
where one or more child progs successfully complete, and a later
child prog fails, and the failure of the later child prog rolls back
the database changes made by the child progs that successfully
complete.  If the child progs are not idempotent, this results in a
situation that cannot be fixed without manual intervention.

Instead, as soon as a child is successfully run inside donate, nap
for 0 seconds.  That will mean the remaining child strands are
skipped during that donate method.  The Nap flow control exception
will be caught inside Strand#unsynchronized_run.  The parent
will update it's own schedule, and the transaction will commit.
Strand#run will handle the Nap 0 exception and if the deadline
hasn't passed, it will immediately rerun the strand. Assuming the
strand still has child processes to run, that will likely get back
to the donate call, where the next child strand will run, repeating
this process until the deadline has passed, all child strands have
run, or there is an error running a child strand.
@jeremyevans jeremyevans requested a review from fdr June 23, 2025 19:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant
0