question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`Log.CloseAndFlush()` deadlock on AWS Lambda

See original GitHub issue

Log.CloseAndFlush() seems to be deadlocking when run in AWS Lambda and my Seq server instance goes down for some (irrelevant) reason making Seq a single point of failure for the whole microservice gang. This is how it looks like in the logs:

LoggerTimeout

This only happens when running in AWS Lambda environment. In a console app execution continues after a graceful timeout of ~4 seconds. I suspect it might be related to this and followed this advice to make it behave better:

...
finally
{
    Task.Run(Log.CloseAndFlush).Wait(1000);
}

It works but still looks like a hack.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
nblumhardtcommented, Sep 13, 2022

Hi @DarkMio; v5.2.0 is out now and includes this fix. I’ll close the ticket as completed but if you notice any ongoing issues please let us know!

1reaction
nblumhardtcommented, Sep 9, 2022

Hi @DarkMio - thanks for reaching out. Starting work on a proper fix for this now via https://github.com/serilog/serilog/pull/1750.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Bug in v7.1.0 with CloseAndFlush hanging app during exit.
When calling Log.CloseAndFlush() my application hangs. Stack trace when hitting pause in a debug session: mscorlib.dll!System.Threading.
Read more >
Why are some Serilog events from AWS lambda not ...
Before your lambda function completes try calling Log.CloseAndFlush(); to ensure any buffered events are processed before the application exits.
Read more >
Concurrency deadlock | Amazon CodeGuru, Detector Library
A deadlock can occur when two distinct threads try to acquire two locks in reverse order. Detector ID. java/concurrency-deadlock@v1.0. Category. Security.
Read more >
AWS Lambda function logging in Java
This page describes how to produce log output from your Lambda function's code, or access logs using the AWS Command Line Interface, the...
Read more >
Parsing logs and structured logging - AWS Lambda
Many developers use unstructured logging in their Lambda functions by using commands such as Python's print function. This creates human-readable output ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found