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

Graceful cancellation period on function timeout #2380

Closed
dmytro-gokun opened this issue Apr 4, 2024 · 4 comments
Closed

Graceful cancellation period on function timeout #2380

dmytro-gokun opened this issue Apr 4, 2024 · 4 comments

Comments

@dmytro-gokun
Copy link

Description

When a function call is being cancelled because of the execution timeout, it does not seem that the CancellationToken passed to it being signaled. Instead, the function app simply exits. Would not it make more sense if the timeout-related shutdown was performed in a bit more 'graceful' way, i.e. CancellationToken signaled and some (configurable) graceful shutdown period allowed (e.g. 10 sec by default)?

@dmytro-gokun dmytro-gokun added the enhancement New feature or request label Apr 4, 2024
@liliankasem liliankasem added needs-investigation and removed enhancement New feature or request labels Apr 9, 2024
@liliankasem
Copy link
Member

Hi @dmytro-gokun, a cancellation token should be getting signaled on function timeout, I believe there a graceful shutdown period of a couple seconds but is not configurable.

Can you share more details about the issue you're seeing? If you're able to share a region, timestamp and invocation ID I should be able to investigate further. Thanks!

@dmytro-gokun
Copy link
Author

@liliankasem I did some testing and I think you are right about CancellationToken and 2 second timeout. The reason i thought cancellation token was not signaled is that i have code like this:

    public class Function
    {
        [Function("Function")]
        public async Task Run(
            [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post")] 
            HttpRequestData request,
            CancellationToken cancellationToken)
        {
            try
            {
                await DoWork(cancellationToken);
            }
            catch (OperationCanceledException)
            {
                Log.LogInformation("Canceled");
            }
        }
    }

with logs being set to Application Insights. So, that "Canceled" log does not end up in AI. I think the reason for that is that the worker gets restarted after the function timeout and some AI logs are lost. Not 100% sure about this though...

@liliankasem
Copy link
Member

If the issue is with AppInsights ingestion then I think we can track these issues in your other GH issue and close this one?

@dmytro-gokun
Copy link
Author

Agree

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants