Azure durable functions - status is running even a

2019-08-28 22:47发布

问题:

Related to my previous question - link

I have created a Durable job with HttpStart in order to call it via http request (code from sample code from MSDN).

In my Durable job, I wrote logic to loop and call an activity trigger 600 times.

public static async Task<List<BusinessRules.RuleResponse>> Run(
    [OrchestrationTrigger] DurableOrchestrationContext context)
{
    var data = await context.CallActivityAsync<BusinessRules.CustomersData>("XmlDeserialiser");

    var tasks = new List<Task<BusinessRules.RuleResponse>>();

    for (int i = 0; i < 600; i++)
    {
        tasks.Add(context.CallActivityAsync<BusinessRules.RuleResponse>("Rule1", data));
        // tasks.Add(context.CallActivityAsync<BusinessRules.RuleResponse>("Rule2", data));
        // tasks.Add(context.CallActivityAsync<BusinessRules.RuleResponse>("Rule2", data));
    }
    await Task.WhenAll(tasks);

    var result = tasks.Select(x => x.Result).ToList();
    return result;     
}

The activitytrigger does is just delay for 10 ms and then return object.

[FunctionName("Rule1")]
public static async Task<BusinessRules.RuleResponse> Run(
    [ActivityTrigger] BusinessRules.CustomersData data)
{
     await Task.Delay(10);
     return new BusinessRules.RuleResponse()
     {
         IsValid = true,
         RuleName = "Rule1"
     };
} 

Idea behind this exercise is my Durable function should be executing 600 business validation rules for each request it receives.

The job status is always coming back as "Running" when I execute the above function with 600 loop. If change the loop count to 500, its working without any problem and returns the result. I tested this on my local machine and on Azure. Its the same in both the environments. However, in my local machine, I found that the job gets completed and I could get the debug point hit in my Durablefunction at return result; but the status is always displaying as "running".

It looks like Durable functions completed the job but for some reason the data wasnt logged in to the Azure storage tables and hence status is still running.

Please advise.

回答1:

Given that it works with smaller numbers and not larger numbers, my guess is that you're running into an issue caused by our lack of support for large messages. Another user opened a similar issue here, and you might be seeing the same symptoms.

If so, the problem is the size of the data returned by this line:

var result = tasks.Select(x => x.Result).ToList();

The size of the serialized data (which gets serialized into JSON and stored as UTF-32 data in Azure Storage) must not exceed 64 KB. If you remove the return value or if you return a smaller value, does the orchestrator complete in the 600 case?

In the short term, we plan on addressing the symptom by throwing an exception when someone attempts to return too much data from a function. Longer term we'll add support for arbitrarily large return values.