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(meta): purge hummock state table after pre apply drop command #17274

Merged
merged 2 commits into from
Jun 17, 2024
Merged
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
52 changes: 22 additions & 30 deletions src/meta/src/barrier/recovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,30 +313,22 @@ impl GlobalBarrierManagerContext {
let (dropped_actors, cancelled) = scheduled_barriers.pre_apply_drop_cancel_scheduled();
let applied = !dropped_actors.is_empty() || !cancelled.is_empty();
if !cancelled.is_empty() {
let unregister_table_ids = match &self.metadata_manager {
match &self.metadata_manager {
MetadataManager::V1(mgr) => {
mgr.fragment_manager
.drop_table_fragments_vec(&cancelled)
.await?
.await?;
}
MetadataManager::V2(mgr) => {
let mut unregister_table_ids = Vec::new();
for job_id in cancelled {
let (_, table_ids_to_unregister) = mgr
.catalog_controller
mgr.catalog_controller
.try_abort_creating_streaming_job(job_id.table_id as _, true)
.await?;
unregister_table_ids.extend(table_ids_to_unregister);
}
unregister_table_ids
.into_iter()
.map(|table_id| table_id as u32)
.collect()
}
};
self.hummock_manager
.unregister_table_ids(&unregister_table_ids)
.await?;
// no need to unregister state table id from hummock manager here, because it's expected that
// we call `purge_state_table_from_hummock` anyway after the current method returns.
}
Ok(applied)
}
Expand Down Expand Up @@ -377,11 +369,6 @@ impl GlobalBarrierManager {
.await
.context("clean dirty streaming jobs")?;

self.context
.purge_state_table_from_hummock()
.await
.context("purge state table from hummock")?;

// Mview progress needs to be recovered.
tracing::info!("recovering mview progress");
self.context
Expand Down Expand Up @@ -436,18 +423,6 @@ impl GlobalBarrierManager {
})?
};

let mut control_stream_manager =
ControlStreamManager::new(self.context.clone());

control_stream_manager
.reset(prev_epoch.value().0, active_streaming_nodes.current())
.await
.inspect_err(|err| {
warn!(error = %err.as_report(), "reset compute nodes failed");
})?;

self.context.sink_manager.reset().await;

if self
.context
.pre_apply_drop_cancel(&self.scheduled_barriers)
Expand All @@ -462,6 +437,23 @@ impl GlobalBarrierManager {
})?
}

self.context
.purge_state_table_from_hummock()
.await
.context("purge state table from hummock")?;

let mut control_stream_manager =
ControlStreamManager::new(self.context.clone());

control_stream_manager
.reset(prev_epoch.value().0, active_streaming_nodes.current())
.await
.inspect_err(|err| {
warn!(error = %err.as_report(), "reset compute nodes failed");
})?;

self.context.sink_manager.reset().await;

// update and build all actors.
self.context.update_actors(&info).await.inspect_err(|err| {
warn!(error = %err.as_report(), "update actors failed");
Expand Down
19 changes: 4 additions & 15 deletions src/meta/src/controller/streaming_job.rs
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ impl CatalogController {
&self,
job_id: ObjectId,
is_cancelled: bool,
) -> MetaResult<(bool, Vec<TableId>)> {
) -> MetaResult<bool> {
let inner = self.inner.write().await;
let txn = inner.db.begin().await?;

Expand All @@ -421,7 +421,7 @@ impl CatalogController {
id = job_id,
"streaming job not found when aborting creating, might be cleaned by recovery"
);
return Ok((true, Vec::new()));
return Ok(true);
}

if !is_cancelled {
Expand All @@ -436,7 +436,7 @@ impl CatalogController {
id = job_id,
"streaming job is created in background and still in creating status"
);
return Ok((false, Vec::new()));
return Ok(false);
}
}
}
Expand All @@ -449,13 +449,6 @@ impl CatalogController {
.all(&txn)
.await?;

let mv_table_id: Option<TableId> = Table::find_by_id(job_id)
.select_only()
.column(table::Column::TableId)
.into_tuple()
.one(&txn)
.await?;

let associated_source_id: Option<SourceId> = Table::find_by_id(job_id)
.select_only()
.column(table::Column::OptionalAssociatedSourceId)
Expand All @@ -476,11 +469,7 @@ impl CatalogController {
}
txn.commit().await?;

let mut state_table_ids = internal_table_ids;

state_table_ids.extend(mv_table_id.into_iter());

Ok((true, state_table_ids))
Ok(true)
}

pub async fn post_collect_table_fragments(
Expand Down
2 changes: 1 addition & 1 deletion src/meta/src/rpc/ddl_controller_v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ impl DdlController {
self.env.event_log_manager_ref().add_event_logs(vec![
risingwave_pb::meta::event_log::Event::CreateStreamJobFail(event),
]);
let (aborted, _) = mgr
let aborted = mgr
.catalog_controller
.try_abort_creating_streaming_job(job_id as _, false)
.await?;
Expand Down
Loading