microsoft / durabletask-mssql

Microsoft SQL storage provider for Durable Functions and the Durable Task Framework
MIT License
87 stars 32 forks source link

Is payload text can save the detail exception or custom information from activity? #230

Closed jarvan-jiang closed 1 month ago

jarvan-jiang commented 4 months ago

Right now if a TaskFailedException is thrown in execution of Activity, the reason can be saved into payload. But how to save the other information like exception detail into payload text too?

davidmrdavid commented 2 months ago

Hi @jarvan-jiang - can you please clarify your question? A concrete example of what you're looking to save would help me understand. Thanks

jarvan-jiang commented 2 months ago

Hi @jarvan-jiang - can you please clarify your question? A concrete example of what you're looking to save would help me understand. Thanks

Hi @davidmrdavid , sorry make you confusion, let me try to explain more. What I mean is, when I throw TaskFailureException in an Activity, the first parameter reason of TaskFailureException will be stored in Payloads table, which is nice. However, the rest like innerException and details are not saved.

        public TaskFailureException(string reason, Exception innerException, string details)
            : base(reason, innerException)
        {
            Details = details;
        }

Is there is a way to save more info like stacktrace or detailed exception from the rest parameters than reason? Or I have to manually put all the info into reason?

davidmrdavid commented 2 months ago

Thanks @jarvan-jiang.

I did a bit triage here, the answer is not immediately obvious to me, but I wanted to document some findings here.

First - the Payload table schema is specified here:

https://github.com/microsoft/durabletask-mssql/blob/e5155826631f8abc8852c1adeb41e958ca4870d7/src/DurableTask.SqlServer/Scripts/schema-1.0.0.sql#L29-L41

There I can see a Text field that I expect may serve as a "catch all" to serialize all sorts of information. This your exception details would probably go, I think.

I also see that when we read from the database, we do try to read the failure details, at least if the if-statement branch in the snippet below is taken:

https://github.com/microsoft/durabletask-mssql/blame/e5155826631f8abc8852c1adeb41e958ca4870d7/src/DurableTask.SqlServer/SqlUtils.cs#L171-L187

and I see that if-statement branch is taken if the Payload column contains a JSON:

https://github.com/microsoft/durabletask-mssql/blob/e5155826631f8abc8852c1adeb41e958ca4870d7/src/DurableTask.SqlServer/SqlUtils.cs#L225-L237

This was implemented here: https://github.com/microsoft/durabletask-mssql/pull/188

So this brings me to a few questions: (1) What package and version of DurableTask MSSQL are you using? Please list the package name (there's multiple, depending on whether you're running DTFx directly, or running Durable Functions / serverless) and the version? (2) Do you see anything in the Payload column for your task failures? (3) Looking at the aformentioned PR, there should be a new configuration called ErrorPropagationMode.UseFailureDetails which should serialize these extra details. Is that something you've set or can try setting? If you can try setting it and reproduce with it, that would help us proceed further.

I also see a report here that the new failure mode may have some edge cases when sub-orchestrators and their activities are involved. Please take a look and let me know if this matches your symptoms. Thanks!

microsoft-github-policy-service[bot] commented 1 month ago

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.