-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[BUG] Exception when saving workflow execution logs after running alterations when using MongoDb storage #5897
Comments
Hi @sfmskywalker! I would be happy to code a fix for this for 3.2.0, if you let me know which approach you prefer for the fix:
|
Hi @rosca-sabina , thank you for reporting this issue and your offer to help. I think we should do both:
Thanks again! |
Hello! I opened a PR with a fix for the issue, please let me know what you think: #5911. I added a new property to class |
Description
When using MongoDB as storage and the default workflow runtime and default workflow execution pipeline, an exception is thrown and recorded as an incident on the WorkflowExecutionContext when running an alteration on an existing workflow instance. The exception's stack trace is:
Steps to Reproduce
To help us identify the issue more quickly, please follow these guidelines:
Detailed Steps:
IWorkflowRuntime.StartWorkflowAsync.StartWorkflowAsync(string definitionId, StartWorkflowRuntimeParams? options)
.IAlterationRunner.RunAsync(string workflowInstanceId, IEnumerable<IAlteration> alterations, CancellationToken cancellationToken)
.IWorkflowRuntime.ExportWorkflowStateAsync(string workflowInstanceId, CancellationToken cancellationToken)
. The workflow state'sIncidents
property will contain an incident with the exception I described under description, even if the alteration was run successfully (denoted byRunAlterationsResult.IsSuccessful
beingtrue
).Attachments:
Reproduction Rate: The issue appears every time in the given conditions.
Expected Behavior
I expect to be able to run alterations when using MongoDB as storage without having incidents on the workflow instance.
Actual Behavior
When using MongoDB as storage, running alterations on a workflow instance causes
Environment
Log Output
This warning is logged from
EngineExceptionHandlingMiddleware
:Troubleshooting Attempts
The root cause of the bug seems to be:
DefaultAlterationRunner
replaces the last middleware with the workflow execution pipeline withRunAlterationsMiddleware
.RunAlterationsMiddleware
runs the alterations on the workflow instance, but doesn't add any execution logs in collectionWorkflowExecutionContext.ExecutionLog
.PersistWorkflowExecutionLogMiddleware
tries to persist the workflow execution logs fromWorkflowExecutionContext.ExecutionLog
, butWorkflowExecutionContext.ExecutionLog
is empty. When using MongoDB for storage,MongoWorkflowExecutionLogStore.AddManyAsync(IEnumerable<WorkflowExecutionLogRecord> records, CancellationToken cancellationToken)
throws an exception when it's passed an empty collection for parameterrecords
.The possible solutions would be to either:
WorkflowExecutionContext.ExecutionLog
.StoreWorkflowExecutionLogSink.PersistExecutionLogsAsync(WorkflowExecutionContext context, CancellationToken cancellationToken)
, add a check that checks ifWorkflowExecutionContext.ExecutionLog
has any logs before attempting to persist them.The text was updated successfully, but these errors were encountered: