feat: Do not trigger the race flush if an ongoing continuous flush is… by astuyve · Pull Request #828 · DataDog/datadog-lambda-extension
Conversation
In rare cases a function will begin a continuous flush then become idle for a while. If and when it wakes back up, the race flush timer may trigger causing a pretty painful resource tie-up as the race flush will begin along with a new invocation as well as potentially another flush redrive/continuous flush. I noticed this can cause occasional timeouts.
| //Periodic flush scenario, flush at top of invocation | ||
| if current_flush_decision == FlushDecision::Continuous { | ||
| if current_flush_decision == FlushDecision::Continuous | ||
| && !pending_flush_handles.has_pending_handles() |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This prevents multiple flush tasks from piling up
| })); | ||
| } | ||
|
|
||
| while let Some(result) = join_set.join_next().await { |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previously this code would await each request serially. At the time I didn't expect that to be an issue because it was being called from another task but ultimately it does slow things down as the final flush task was driving these serially
astuyve
marked this pull request as ready for review
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters