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

RestartWorkflow PanicPolicy #1369

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions internal/internal_task_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -1193,6 +1193,16 @@ func (w *workflowExecutionContextImpl) applyWorkflowPanicPolicy(workflowTask *wo
w.getEventHandler().Complete(nil, NewApplicationError(
"Workflow failed on panic due to FailWorkflow workflow panic policy",
"", false, workflowError))
case RestartWorkflow:
// return an error to restart the workflow
// TODO: Get Workflow Context and inputs somehow and have a full ContinueAsNewError
// current error only works if the workflow does not have any input
w.getEventHandler().Complete(nil, &ContinueAsNewError{
WorkflowType: &w.workflowInfo.WorkflowType,
TaskQueueName: w.workflowInfo.TaskQueueName,
WorkflowRunTimeout: w.workflowInfo.WorkflowRunTimeout,
WorkflowTaskTimeout: w.workflowInfo.WorkflowTaskTimeout,
})
case BlockWorkflow:
// return error here will be convert to WorkflowTaskFailed for the first time, and ignored for subsequent
// attempts which will cause WorkflowTaskTimeout and server will retry forever until issue got fixed or
Expand Down
3 changes: 3 additions & 0 deletions internal/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,9 @@ const (
// This feature is convenient during development.
// WARNING: enabling this in production can cause all open workflows to fail on a single bug or bad deployment.
FailWorkflow
// RestartWorkflow immediately restarts the workflow execution if workflow code throws panic or detects non-determinism.
// This feature is convenient if the workflows are finite state machines
RestartWorkflow
)

// ReplayNamespace is namespace for replay because startEvent doesn't contain it
Expand Down
3 changes: 3 additions & 0 deletions worker/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,9 @@ const (
// detects non-determinism. This feature is convenient during development.
// WARNING: enabling this in production can cause all open workflows to fail on a single bug or bad deployment.
FailWorkflow = internal.FailWorkflow
// RestartWorkflow immediately restarts the workflow execution if workflow code throws panic or detects non-determinism.
// This feature is convenient if the workflows are finite state machines
RestartWorkflow = internal.RestartWorkflow
)

// New creates an instance of worker for managing workflow and activity executions.
Expand Down