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

fix: all_running_fragment_mappings return result instead of panic #17722

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/meta/service/src/notification_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,7 @@ impl NotificationServiceImpl {
match &self.metadata_manager {
MetadataManager::V1(mgr) => {
let fragment_guard = mgr.fragment_manager.get_fragment_read_guard().await;
let worker_slot_mappings =
fragment_guard.all_running_fragment_mappings().collect_vec();
let worker_slot_mappings = fragment_guard.all_running_fragment_mappings()?;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer to add a warning and return empty mapping to FE, so that the catalogs can still be visible, dropped, cancelled etc and also be able to queried in singleton.

let notification_version = self.env.notification_manager().current_version().await;
Ok((worker_slot_mappings, notification_version))
}
Expand Down
47 changes: 26 additions & 21 deletions src/meta/src/manager/catalog/fragment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,27 +58,32 @@ pub struct FragmentManagerCore {

impl FragmentManagerCore {
/// List all fragment vnode mapping info that not in `State::Initial`.
pub fn all_running_fragment_mappings(
&self,
) -> impl Iterator<Item = FragmentWorkerSlotMapping> + '_ {
self.table_fragments
.values()
.filter(|tf| tf.state() != State::Initial)
.flat_map(|table_fragments| {
table_fragments
.fragments
.values()
.map(move |fragment| FragmentWorkerSlotMapping {
fragment_id: fragment.fragment_id,
mapping: Some(
FragmentManager::convert_mapping(
&table_fragments.actor_status,
fragment.vnode_mapping.as_ref().unwrap(),
)
.unwrap(),
),
})
})
pub fn all_running_fragment_mappings(&self) -> MetaResult<Vec<FragmentWorkerSlotMapping>> {
let mut mappings = vec![];

for table_fragments in self.table_fragments.values() {
if table_fragments.state() == State::Initial {
continue;
}

for fragment in table_fragments.fragments() {
let worker_slot_mapping = FragmentManager::convert_mapping(
&table_fragments.actor_status,
fragment.vnode_mapping.as_ref().unwrap(),
)
.inspect_err(|e| tracing::warn!("build mapping failed: {:?}, downgrade to None", e))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.inspect_err(|e| tracing::warn!("build mapping failed: {:?}, downgrade to None", e))
.inspect_err(|e| tracing::warn!(error = %e.as_report(), "build mapping failed, downgrade to None"))

.ok();

let mapping = FragmentWorkerSlotMapping {
fragment_id: fragment.fragment_id,
mapping: worker_slot_mapping,
};

mappings.push(mapping);
}
}

Ok(mappings)
}

fn running_fragment_parallelisms(
Expand Down
Loading