-
Notifications
You must be signed in to change notification settings - Fork 43
feat: support unsubscribe partition #256
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
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 |
|---|---|---|
|
|
@@ -409,6 +409,19 @@ impl LogScannerInner { | |
| Ok(()) | ||
| } | ||
|
|
||
| async fn unsubscribe_partition(&self, partition_id: PartitionId, bucket: i32) -> Result<()> { | ||
| if !self.is_partitioned_table { | ||
| return Err(Error::UnsupportedOperation { | ||
| message: "Can't unsubscribe a partition for a non-partitioned table.".to_string(), | ||
| }); | ||
| } | ||
| let table_bucket = | ||
| TableBucket::new_with_partition(self.table_id, Some(partition_id), bucket); | ||
| self.log_scanner_status | ||
| .unassign_scan_buckets(from_ref(&table_bucket)); | ||
| Ok(()) | ||
| } | ||
|
Comment on lines
+412
to
+423
|
||
|
|
||
| async fn poll_for_fetches(&self) -> Result<HashMap<TableBucket, Vec<ScanRecord>>> { | ||
| let result = self.log_fetcher.collect_fetches()?; | ||
| if !result.is_empty() { | ||
|
|
@@ -487,6 +500,14 @@ impl LogScanner { | |
| .subscribe_partition(partition_id, bucket, offset) | ||
| .await | ||
| } | ||
|
|
||
| pub async fn unsubscribe_partition( | ||
| &self, | ||
| partition_id: PartitionId, | ||
| bucket: i32, | ||
| ) -> Result<()> { | ||
| self.inner.unsubscribe_partition(partition_id, bucket).await | ||
| } | ||
|
Comment on lines
+504
to
+510
|
||
| } | ||
|
|
||
| // Implementation for RecordBatchLogScanner (batches mode) | ||
|
|
@@ -514,6 +535,14 @@ impl RecordBatchLogScanner { | |
| .subscribe_partition(partition_id, bucket, offset) | ||
| .await | ||
| } | ||
|
|
||
| pub async fn unsubscribe_partition( | ||
| &self, | ||
| partition_id: PartitionId, | ||
| bucket: i32, | ||
| ) -> Result<()> { | ||
| self.inner.unsubscribe_partition(partition_id, bucket).await | ||
| } | ||
| } | ||
|
|
||
| struct LogFetcher { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The unsubscribe_partition method doesn't call check_and_update_table_metadata like subscribe_partition does. All subscribe methods (subscribe, subscribe_batch, and subscribe_partition) update the table metadata before modifying the scanner state. For consistency and to ensure the scanner has the latest table information, unsubscribe_partition should also call check_and_update_table_metadata before unassigning buckets. This ensures that partition metadata is current when unsubscribing.