-
-
Notifications
You must be signed in to change notification settings - Fork 5
feat(postgres): Change the Postgres Adapter to be Partition Aware #591
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
Changes from all commits
f70bfda
04b13bd
1019655
001ad1a
3fbebe0
010bab3
51e7649
a7eaa6f
234e722
7ed5a7a
d08af4f
4c29aee
c8322ad
086f6b5
d405fac
c1b9f8e
05125fe
3d90685
d2e86f6
94b41c2
895e119
f97d2ad
bc48c78
51c1889
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| use crate::store::inflight_activation::InflightActivationStore; | ||
| use anyhow::{Error, anyhow}; | ||
| use futures::{ | ||
| Stream, StreamExt, | ||
|
|
@@ -44,6 +45,7 @@ use tracing::{debug, error, info, instrument, warn}; | |
| pub async fn start_consumer( | ||
| topics: &[&str], | ||
| kafka_client_config: &ClientConfig, | ||
| activation_store: Arc<dyn InflightActivationStore>, | ||
| spawn_actors: impl FnMut( | ||
| Arc<StreamConsumer<KafkaContext>>, | ||
| &BTreeSet<(String, i32)>, | ||
|
|
@@ -68,6 +70,7 @@ pub async fn start_consumer( | |
| handle_events( | ||
| consumer, | ||
| event_receiver, | ||
| activation_store, | ||
| client_shutdown_sender, | ||
| spawn_actors, | ||
| ) | ||
|
|
@@ -340,6 +343,7 @@ enum ConsumerState { | |
| pub async fn handle_events( | ||
| consumer: Arc<StreamConsumer<KafkaContext>>, | ||
| events: UnboundedReceiver<(Event, SyncSender<()>)>, | ||
| activation_store: Arc<dyn InflightActivationStore>, | ||
| shutdown_client: oneshot::Sender<()>, | ||
| mut spawn_actors: impl FnMut( | ||
| Arc<StreamConsumer<KafkaContext>>, | ||
|
|
@@ -372,6 +376,12 @@ pub async fn handle_events( | |
| state = match (state, event) { | ||
| (ConsumerState::Ready, Event::Assign(tpl)) => { | ||
| metrics::gauge!("arroyo.consumer.current_partitions").set(tpl.len() as f64); | ||
| // Note: This assumes we only process one topic per consumer. | ||
| let mut partitions = Vec::<i32>::new(); | ||
| for (_, partition) in tpl.iter() { | ||
| partitions.push(*partition); | ||
| } | ||
| activation_store.assign_partitions(partitions).unwrap(); | ||
| ConsumerState::Consuming(spawn_actors(consumer.clone(), &tpl), tpl) | ||
| } | ||
| (ConsumerState::Ready, Event::Revoke(_)) => { | ||
|
|
@@ -386,11 +396,13 @@ pub async fn handle_events( | |
| tpl == revoked, | ||
| "Revoked TPL should be equal to the subset of TPL we're consuming from" | ||
| ); | ||
| activation_store.assign_partitions(vec![]).unwrap(); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Partitions cleared before actors shutdown causes unscoped queriesMedium Severity
Additional Locations (1)Reviewed by Cursor Bugbot for commit 51c1889. Configure here.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Evan thinks this is fine. |
||
| handles.shutdown(CALLBACK_DURATION).await; | ||
| metrics::gauge!("arroyo.consumer.current_partitions").set(0); | ||
|
Comment on lines
396
to
401
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: Clearing the partition filter via Suggested FixThe partition filter should be cleared after the actor handles have been successfully shut down. Move the Prompt for AI Agent
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Evan thinks this is fine. |
||
| ConsumerState::Ready | ||
| } | ||
| (ConsumerState::Consuming(handles, _), Event::Shutdown) => { | ||
| activation_store.assign_partitions(vec![]).unwrap(); | ||
| handles.shutdown(CALLBACK_DURATION).await; | ||
| debug!("Signaling shutdown to client..."); | ||
| shutdown_client.take(); | ||
|
|
||


Uh oh!
There was an error while loading. Please reload this page.