feat: Do not trigger the race flush if an ongoing continuous flush is… by astuyve · Pull Request #828 · DataDog/datadog-lambda-extension

Conversation

@astuyve

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.

duncanista

astuyve

//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

astuyve

}));
}

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 astuyve marked this pull request as ready for review

September 16, 2025 16:17

duncanista

2 participants

@astuyve @duncanista