Skip to content

Conversation

@llucax
Copy link
Contributor

@llucax llucax commented Jun 26, 2024

The data sourcing actor is parallelizing the sending of samples to the stream senders, but it was not properly keeping references to the tasks and awaiting for them to finish.

References were probably kept by gather(), but gather() wasn't awaited, so it can potentially not run at all (although it seems it did, because things were working).

This commit uses a TaskGroup to keep references to the tasks in process_msg() and then makes each process_msg() call a task too, but we don't use a task group here because we don't want to await until a batch of messages is sent before receiving the next one. Instead, we want to keep sending messages in the background. But we still need to clean up these tasks as soon as they are done.

This replaces the event used to wait until there are no more pending messages to be sent, as it is enough to synchronize awaiting for the (pending) tasks to finish.

This was discovered while looking at warnings in the tests (#982).

@llucax llucax requested a review from a team as a code owner June 26, 2024 12:05
@github-actions github-actions bot added the part:actor Affects an actor ot the actors utilities (decorator, etc.) label Jun 26, 2024
@llucax llucax added this to the v1.0.0-rc800 milestone Jun 26, 2024
@llucax llucax self-assigned this Jun 26, 2024
@llucax llucax requested a review from shsms June 26, 2024 12:05
@llucax llucax added the type:bug Something isn't working label Jun 26, 2024
@llucax llucax enabled auto-merge June 26, 2024 12:06
@github-actions github-actions bot added the part:docs Affects the documentation label Jun 26, 2024
@llucax llucax added this pull request to the merge queue Jun 26, 2024
The data sourcing actor is parallelizing the sending of samples to the
stream senders, but it was not properly keeping references to the tasks
and awaiting for them to finish.

References were probably kept by `gather()`, but `gather()` wasn't
awaited, so it can potentially not run at all (although it seems it did,
because things were working).

This commit uses a `TaskGroup` to keep references to the tasks in
`process_msg()` and then makes each `process_msg()` call a task too, but
we don't use a task group here because we don't want to await until
a batch of messages is sent before receiving the next one. Instead, we
want to keep sending messages in the background. But we still need to
clean up these tasks as soon as they are done.

This replaces the event used to wait until there are no more pending
messages to be sent, as it is enough to synchronize awaiting for the
(pending) tasks to finish.

Signed-off-by: Leandro Lucarella <[email protected]>
Merged via the queue into frequenz-floss:v1.x.x with commit 04ad6e6 Jun 26, 2024
@llucax llucax deleted the await-tasks branch June 26, 2024 12:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

part:actor Affects an actor ot the actors utilities (decorator, etc.) part:docs Affects the documentation type:bug Something isn't working

Projects

Development

Successfully merging this pull request may close these issues.

2 participants