MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / run_export

Method run_export

src/storage-controller/src/lib.rs:3429–3486  ·  view source on GitHub ↗

Runs the identified export using the current definition of the export that we have in memory.

(&mut self, id: GlobalId)

Source from the content-addressed store, hash-verified

3427 /// Runs the identified export using the current definition of the export
3428 /// that we have in memory.
3429 fn run_export(&mut self, id: GlobalId) -> Result<(), StorageError> {
3430 let DataSource::Sink { desc: description } = &self.collections[&id].data_source else {
3431 return Err(StorageError::IdentifierMissing(id));
3432 };
3433
3434 let from_storage_metadata = self
3435 .storage_collections
3436 .collection_metadata(description.sink.from)?;
3437 let to_storage_metadata = self.storage_collections.collection_metadata(id)?;
3438
3439 // Choose an as-of frontier for this execution of the sink. If the write frontier of the sink
3440 // is strictly larger than its read hold, it must have at least written out its snapshot, and we can skip
3441 // reading it; otherwise assume we may have to replay from the beginning.
3442 let export_state = self.storage_collections.collection_frontiers(id)?;
3443 let mut as_of = description.sink.as_of.clone();
3444 as_of.join_assign(&export_state.implied_capability);
3445 let with_snapshot = description.sink.with_snapshot
3446 && !PartialOrder::less_than(&as_of, &export_state.write_frontier);
3447
3448 info!(
3449 sink_id = %id,
3450 from_id = %description.sink.from,
3451 write_frontier = ?export_state.write_frontier,
3452 ?as_of,
3453 ?with_snapshot,
3454 "run_export"
3455 );
3456
3457 let cmd = RunSinkCommand {
3458 id,
3459 description: StorageSinkDesc {
3460 from: description.sink.from,
3461 from_desc: description.sink.from_desc.clone(),
3462 connection: description.sink.connection.clone(),
3463 envelope: description.sink.envelope,
3464 as_of,
3465 version: description.sink.version,
3466 from_storage_metadata,
3467 with_snapshot,
3468 to_storage_metadata,
3469 commit_interval: description.sink.commit_interval,
3470 },
3471 };
3472
3473 let storage_instance_id = description.instance_id.clone();
3474
3475 let instance = self
3476 .instances
3477 .get_mut(&storage_instance_id)
3478 .ok_or_else(|| StorageError::ExportInstanceMissing {
3479 storage_instance_id,
3480 export_id: id,
3481 })?;
3482
3483 instance.send(StorageCommand::RunSink(Box::new(cmd)));
3484
3485 Ok(())
3486 }

Callers 1

Calls 6

join_assignMethod · 0.80
collection_metadataMethod · 0.45
collection_frontiersMethod · 0.45
cloneMethod · 0.45
get_mutMethod · 0.45
sendMethod · 0.45

Tested by

no test coverage detected