-
Notifications
You must be signed in to change notification settings - Fork 50
Patching #524
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
Merged
Merged
Patching #524
+414
−5
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Contributor
|
How would I use this patching system to fix a workflow? Manually fork from the step before the patch? |
qianl15
reviewed
Nov 24, 2025
qianl15
reviewed
Nov 24, 2025
qianl15
reviewed
Nov 24, 2025
qianl15
reviewed
Nov 24, 2025
qianl15
approved these changes
Dec 8, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Patching is a mechanism for safely upgrading workflow code. It is an alternative to workflow versioning (though they can be used together).
The problem patching solves is "How do I make a breaking change to a workflow's code but continue execution of long-running workflows that started on the old code version?" A breaking change is any change in what steps run or the order in which they run.
To use patching, first enable it in configuration:
Next, when making a breaking change, use an
if DBOS.patch():conditional.DBOS.patch()returnsTruefor new workflows (those started after the breaking change) andFalsefor old workflows (those started before the breaking change). Therefore, ifDBOS.patch()is true, call the new code, else call the old code.So let's say our workflow is:
We want to replace the call to
foo()with a call tobaz(), which is a breaking change. We can do this safely using a patch:Now, new workflows will run
baz(), while old workflows will safely recover throughfoo().Once all workflows of the pre-patch code version are complete, we can remove patches from our code. First, we deprecate the patch. This will safely run workflows containing the patch marker, but will not insert the patch marker into new workflows:
Then, when all workflows containing the patch marker are complete, we can remove the patch entirely and complete the workflow upgrade!
If any mistakes happen during the process (a breaking change is not patched, or a patch is deprecated or removed prematurely), the workflow will throw a clean
DBOSUnexpectedStepErrorpointing to the step where the problem occurred.Also, one advanced feature is that if you need to make consecutive breaking changes to the same code, you can stack patches: