Skip to content
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
24 changes: 21 additions & 3 deletions src/adapter/src/coord.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ use mz_catalog::memory::objects::{
};
use mz_cloud_resources::{CloudResourceController, VpcEndpointConfig, VpcEndpointEvent};
use mz_compute_client::as_of_selection;
use mz_compute_client::controller::error::InstanceMissing;
use mz_compute_client::controller::error::{DataflowCreationError, InstanceMissing};
use mz_compute_types::ComputeInstanceId;
use mz_compute_types::dataflows::DataflowDescription;
use mz_compute_types::plan::Plan;
Expand Down Expand Up @@ -3682,23 +3682,41 @@ impl Coordinator {

/// Call into the compute controller to install a finalized dataflow, and
/// initialize the read policies for its exported readable objects.
///
/// # Panics
///
/// Panics if dataflow creation fails.
pub(crate) async fn ship_dataflow(
&mut self,
dataflow: DataflowDescription<Plan>,
instance: ComputeInstanceId,
subscribe_target_replica: Option<ReplicaId>,
) {
self.try_ship_dataflow(dataflow, instance, subscribe_target_replica)
.await
.unwrap_or_terminate("dataflow creation cannot fail");
}

/// Call into the compute controller to install a finalized dataflow, and
/// initialize the read policies for its exported readable objects.
pub(crate) async fn try_ship_dataflow(
&mut self,
dataflow: DataflowDescription<Plan>,
instance: ComputeInstanceId,
subscribe_target_replica: Option<ReplicaId>,
) -> Result<(), DataflowCreationError> {
// We must only install read policies for indexes, not for sinks.
// Sinks are write-only compute collections that don't have read policies.
let export_ids = dataflow.exported_index_ids().collect();

self.controller
.compute
.create_dataflow(instance, dataflow, subscribe_target_replica)
.unwrap_or_terminate("dataflow creation cannot fail");
.create_dataflow(instance, dataflow, subscribe_target_replica)?;

self.initialize_compute_read_policies(export_ids, instance, CompactionWindow::Default)
.await;

Ok(())
}

/// Call into the compute controller to allow writes to the specified IDs
Expand Down
16 changes: 13 additions & 3 deletions src/adapter/src/coord/peek.rs
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,9 @@ impl crate::coord::Coordinator {
self.controller
.compute
.create_dataflow(compute_instance, dataflow, None)
.unwrap_or_terminate("cannot fail to create dataflows");
.map_err(
AdapterError::concurrent_dependency_drop_from_dataflow_creation_error,
)?;
Copy link
Contributor Author

@ggevay ggevay Nov 26, 2025

Choose a reason for hiding this comment

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

This change can possibly affect the old peek sequencing, but I hope that's ok.

self.initialize_compute_read_policies(
output_ids,
compute_instance,
Expand Down Expand Up @@ -1332,8 +1334,16 @@ impl crate::coord::Coordinator {
.await,
);

self.ship_dataflow(df_desc, compute_instance, target_replica)
.await;
// Try to ship the dataflow. We handle errors gracefully because dependencies might have
// disappeared during sequencing.
if let Err(e) = self
.try_ship_dataflow(df_desc, compute_instance, target_replica)
.await
.map_err(AdapterError::concurrent_dependency_drop_from_dataflow_creation_error)
{
let _ = tx.send(Err(e));
return;
}

// Spawn background task to wait for completion
// We must NOT await sink_rx here directly, as that would block the coordinator's main task
Expand Down
23 changes: 23 additions & 0 deletions src/adapter/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,29 @@ impl AdapterError {
e @ PeekError::ReadHoldInsufficient(_) => AdapterError::internal("peek error", e),
}
}

pub fn concurrent_dependency_drop_from_dataflow_creation_error(
e: compute_error::DataflowCreationError,
) -> Self {
use compute_error::DataflowCreationError::*;
match e {
InstanceMissing(id) => AdapterError::ConcurrentDependencyDrop {
dependency_kind: "cluster",
dependency_id: id.to_string(),
},
CollectionMissing(id) => AdapterError::ConcurrentDependencyDrop {
dependency_kind: "collection",
dependency_id: id.to_string(),
},
ReplicaMissing(id) => AdapterError::ConcurrentDependencyDrop {
dependency_kind: "replica",
dependency_id: id.to_string(),
},
MissingAsOf | SinceViolation(..) | EmptyAsOfForSubscribe | EmptyAsOfForCopyTo => {
AdapterError::internal("dataflow creation error", e)
}
}
}
}

impl fmt::Display for AdapterError {
Expand Down