Coalesce function unsubscribes only after receiving 3 samples#1374
Open
simonvoelcker wants to merge 3 commits intofrequenz-floss:v1.x.xfrom
Open
Coalesce function unsubscribes only after receiving 3 samples#1374simonvoelcker wants to merge 3 commits intofrequenz-floss:v1.x.xfrom
simonvoelcker wants to merge 3 commits intofrequenz-floss:v1.x.xfrom
Conversation
dae4a2a to
c69f4a4
Compare
c69f4a4 to
89eb72f
Compare
Signed-off-by: Simon Völcker <simon.voelcker@frequenz.com>
Signed-off-by: Simon Völcker <simon.voelcker@frequenz.com>
Signed-off-by: Simon Völcker <simon.voelcker@frequenz.com>
89eb72f to
6a483f0
Compare
simonvoelcker
commented
Mar 13, 2026
| @@ -0,0 +1,186 @@ | |||
| # License: MIT | |||
| # Copyright © 2025 Frequenz Energy-as-a-Service GmbH | |||
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses #1332.
Background
The Coalesce function subscribes and unsubscribes from components based on data availability. If it receives None-values, it will subscribe to the next component, if any, from its parameter list. Once the other components start sending data again, we may unsubscribe from "later" components. We currently unsubscribe from all components "after" a given one once that given one sends us one non-None sample. This is undesired because we may receive intermittent None values for various reasons and would then unsubscribe and resubscribe excessively.
Change
The solution is to count non-None samples from earlier streams and unsubscribe only once a threshold (3) is reached.
Discussion
If there are only two components (main, backup), it is quite straightforward. With more components, although probably rarely seen in practice, one could come up with a more sophisticated solution that tracks each components samples and marks them as stable when 3 samples are reached. Happy to discuss, but I think it's overkill.