Skip to content
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

feat(sensor): disable leader election for jetstream eventbus #3303

Closed

Conversation

ryancurrah
Copy link
Contributor

@ryancurrah ryancurrah commented Sep 27, 2024

Supersedes #3240

Checklist:

@ryancurrah ryancurrah requested a review from whynowy as a code owner September 27, 2024 13:29
@ryancurrah ryancurrah force-pushed the feat-eventsource-jetstream-ha branch from 9a54370 to 6a644d0 Compare September 27, 2024 14:07
@whynowy
Copy link
Member

whynowy commented Sep 28, 2024

What is the reason leader election is not needed when using jetstream? Assume the trigger relies on events from multiple sources, with multiple sensor instances, it will be an issue right?

@ryancurrah
Copy link
Contributor Author

Leader election is not needed when using JetStream because, like Kafka consumer groups, it supports horizontal scaling through queue subscriptions, which distribute events across multiple sensor instances, ensuring that only one instance processes each event. Similar to Kafka consumer groups, where each message is processed by only one consumer within a group, JetStream queue subscriptions achieve the same event distribution. It is important to ensure that queue subscriptions are enabled; otherwise, if sensor leader election is turned off, all sensor instances will receive and process the same events, leading to duplicate event processing.

Before disabling leader election for JetStream, my PR should verify that queue subscriptions are enabled to ensure that events are handled by only one sensor instance.

Queue subscription support was added in this commit: 5461296.

@whynowy
Copy link
Member

whynowy commented Sep 30, 2024

Leader election is not needed when using JetStream because, like Kafka consumer groups, it supports horizontal scaling through queue subscriptions, which distribute events across multiple sensor instances, ensuring that only one instance processes each event. Similar to Kafka consumer groups, where each message is processed by only one consumer within a group, JetStream queue subscriptions achieve the same event distribution. It is important to ensure that queue subscriptions are enabled; otherwise, if sensor leader election is turned off, all sensor instances will receive and process the same events, leading to duplicate event processing.

Before disabling leader election for JetStream, my PR should verify that queue subscriptions are enabled to ensure that events are handled by only one sensor instance.

Queue subscription support was added in this commit: 5461296.

This is not my concern. My concern is about the following scenario:

Sensor s1 has dependencies on es1 && es2, with multiple sensor instances, those events can go to different pods, which will not be able to meet the && condition.

@ryancurrah
Copy link
Contributor Author

ryancurrah commented Oct 2, 2024

This is not my concern. My concern is about the following scenario:

Sensor s1 has dependencies on es1 && es2, with multiple sensor instances, those events can go to different pods, which will not be able to meet the && condition.

Hrm how does it work for Kafka? I assume the concerns would have also applied to Kafka, and if so how did you solve it for Kafka?

This is the PR in which Kafka was added 95a0877#diff-57d9dbd85ed75b31a65e6880e99ee6ae77344b1760efa44ad73e82a2dce287bcR46

@mweibel
Copy link
Contributor

mweibel commented Nov 28, 2024

so this was closed but my earlier PR related to this (#3240) is still open. Any chance this could go further?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants