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

Document a significant caveat to SideEffect funcs #1399

Merged
merged 3 commits into from
Nov 26, 2024

Conversation

Groxx
Copy link
Member

@Groxx Groxx commented Nov 8, 2024

An unfortunate edge-case-use was discovered recently, and SideEffect does not have adequate protections to prevent breaking workflows at the moment.

For now, just document it.
A true fix will require failing calls to blocking or history-recording funcs while the callback runs, as they cannot be used safely.
Future versions of this API should remove the context arg, to stop implying it can be used.

Copy link

codecov bot commented Nov 8, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.52%. Comparing base (fabd87b) to head (34543d2).
Report is 1 commits behind head on master.

Files with missing lines Coverage Δ
internal/workflow.go 76.24% <ø> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fabd87b...34543d2. Read the comment docs.

// // Bad example: this will work until a replay occurs,
// // but then the workflow will fail to replay with a non-deterministic error.
// var out string
// err := workflow.SideEffect(func(ctx workflow.Context) interface{} {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a ticket/initiative to fix this?
We cannot change the API since it is used everywhere, but we could introduce workflow.Context check will fail in the case of history-related operations inside these calls.
Something like:
workflow.Context{
insideSidefffect: true
}

and inside forbidden things bail out if this flag is set.

Copy link
Member Author

Choose a reason for hiding this comment

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

yea, a context-flag of some kind is I think our only real option, but I haven't dug into that code enough to know how much of an effort it will be. I know we have similar behavior for other things though (in queries maybe?).

I have an internal ticket for it (did so before writing this out), nothing public yet though.

@Groxx Groxx merged commit e3802b7 into cadence-workflow:master Nov 26, 2024
10 of 11 checks passed
@Groxx Groxx deleted the caution-side-effect branch November 26, 2024 00:33
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.

3 participants