-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Join remains Pending until both streams yield an item #12
Comments
@danieldg Is this intentional? 🤔 |
This currently hangs (danieldg#12).
This currently hangs (danieldg#12).
If one of the streams is ready and the other is pending, we should just return the item from the ready stream. Otherwise, join will never resolve until both streams are ready (which could be never). Fixes danieldg#12.
This currently hangs (danieldg#12).
If one of the streams is ready and the other is pending, we should just return the item from the ready stream. Otherwise, join will never resolve until both streams are ready (which could be never). Fixes danieldg#12.
If one of the streams is ready and the other is pending, we should just return the item from the ready stream. Otherwise, join will never resolve until both streams are ready (which could be never). Fixes danieldg#12.
Yes, this was intentional. The fix (and therefore the 0.1.3 and 0.1.4 releases) will produce a stream with items out of order if one of the producing streams is being processed by another task or thread. |
But this breaks zbus. I want items in order but that doesn't mean I want things to just hang forever to make it happen. I could add a timeout in the client but that's a bad workaround. |
Also now that you're not the only one maintaining/developing this, please don't push directly to master and only via PRs, giving me a chance to have a look. |
I don't understand something: how will one of the streams be polled by another task if |
Example: Assume task 1 produces two messages In this instance, the |
Thanks for the example. I thought about it on the tram and realized that the issue is multiple producers. In case of zbus, this doesn't happen and we've a single producer. I guess this means, that within zbus I don't need to use UnorderedStream even. |
I think zbus shouldn't run into this as a visible problem, since any stream it provides should be correctly returning |
Well, you can run |
Here is the problematic code. |
I've found the problem: because of how Fixing this is a bit trickier because you need to communicate new sequence numbers to all interested listeners, not just those whose rule matches. I'll take a shot at doing that. |
That would be very unfortunate and beat one of the main points of the new match rule based API. As I wrote before, I'm not even sure we need this in zbus since we only have 1 producer running in a single task. |
1 similar comment
That would be very unfortunate and beat one of the main points of the new match rule based API. As I wrote before, I'm not even sure we need this in zbus since we only have 1 producer running in a single task. |
Thanks for the discussion @danieldg and @zeenix. My use case for this crate is that I'm dealing with an event-driven system and I need to consume messages (the payloads of the events) from multiple Kafka topics in order to generate a database whose state is the accumulation of all events. But they need to be consumed orderly based on the Kafka timestamp rather than in a race, otherwise I risk getting an incorrect state. With the current behavior, I can only consume an event once all streams have a message ready. This is good because in case one stream has an issue with connection, the others will wait and I'll be sure events are always being consumed in the right order. The not so good news is that I'll never reach a state where all my events are consumed. If one topic has 1,000 messages ready and the other one doesn't receive a message in a week, all 1,000 events will not be in the database during this week. Both behaviors have advantages, but based on the fact that this crate is oriented towards guaranteeing the correct order of items, my understanding is that waiting for all to complete is what most users will expect and like. I'm trying to fix my scenario by making the event streams return |
@guicostaarantes that is actually one of the use-cases that I considered when making this crate. My best thought for a solution for the "long-idle stream" problem is to have each stream produce periodic (hourly or whatever) heartbeat messages that serve to show that the stream is alive but nothing is ready to be sent. If the original stream is adapted using |
This code hangs:
The text was updated successfully, but these errors were encountered: