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
70 changes: 66 additions & 4 deletions crates/adapters/src/controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4516,6 +4516,32 @@ impl CircuitThread {
let silent_bootstrap =
self.silent_bootstrap && self.controller.status.bootstrap_in_progress();

// Whether the bootstrap still owes a re-emission to the endpoints whose
// relations it rebuilds. Until it arrives, those endpoints receive only
// empty batches: a concurrent bootstrap keeps the pre-existing views
// live and steps the primary circuit throughout the backfill. Reporting
// the pipeline's progress on those batches would claim output the
// endpoint never received, so `processed_records` is withheld from them
// until the step that carries the re-emission.
//
// A silent bootstrap owes nothing: it suppresses the re-emission, and
// discarding it is what progress means for those endpoints.
//
// The step that carries the re-emission is excluded. For a concurrent
// bootstrap that is the `Finalizing` step: cutover has installed the new
// views, and the transaction that commits during this phase drains
// their full contents. `self.bootstrapping` is the stop-the-world
// analogue, cleared earlier in `step` on the step that completes the
// bootstrap.
let bootstrap_owes_reemission = !silent_bootstrap
&& (self.bootstrapping
|| matches!(
self.concurrent_phase,
ConcurrentPhase::Backfill
| ConcurrentPhase::AwaitingSync
| ConcurrentPhase::Synchronize
));

let outputs = self.controller.outputs.read().unwrap();
for (_stream, (output_handles, endpoints)) in outputs.iter_by_stream() {
let (mut delta_batch, num_delta_records) = if silent_bootstrap {
Expand All @@ -4532,6 +4558,17 @@ impl CircuitThread {
let endpoint = outputs.lookup_by_id(endpoint_id).unwrap();
let transaction = self.controller.get_transaction_number();

let owed_reemission = bootstrap_owes_reemission
&& self
.controller
.bootstrapped_output_endpoints
.contains(&endpoint.endpoint_name);
let processed_records = if owed_reemission {
None
} else {
processed_records
};

// Silent bootstrap: send empty batch for progress tracking only.
if silent_bootstrap {
self.controller.status.enqueue_batch(*endpoint_id, 0);
Expand Down Expand Up @@ -4572,6 +4609,30 @@ impl CircuitThread {
// delivered its initial snapshot. Deliver the snapshot and
// skip the normal delta path.
if endpoint.control.is_snapshot_pending() {
// A snapshot reflects the state as of the last committed
// transaction, so an endpoint that receives one is up to
// date with the pipeline's own count even mid-transaction,
// where the delta path has no figure to report. An endpoint
// still owed a re-emission is the exception: it gets the
// pre-cutover snapshot, so its counter has to keep waiting.
let processed_records = if owed_reemission {
None
} else {
processed_records.or_else(|| {
Some(ProcessedRecords {
total_processed_input_records: self
.controller
.status
.num_total_processed_records(),
total_processed_steps: self
.controller
.status
.global_metrics
.total_completed_steps(),
})
})
};

self.controller.enqueue_latest_snapshot(
*endpoint_id,
&endpoint.stream_name,
Expand Down Expand Up @@ -7904,6 +7965,11 @@ impl ControllerInner {
/// endpoint's batch queue. Returns `true` if a snapshot was found and
/// enqueued, `false` if no cached snapshot exists yet (e.g., the pipeline
/// hasn't completed its first step).
///
/// `processed_records` means the same here as everywhere else on the batch
/// queue: `None` leaves the endpoint's progress counter alone. The caller
/// decides what to report; it is the one that knows whether the endpoint is
/// still owed output.
#[allow(clippy::too_many_arguments)]
fn enqueue_latest_snapshot(
&self,
Expand Down Expand Up @@ -7932,10 +7998,6 @@ impl ControllerInner {
return false;
};

let processed_records = processed_records.or(Some(ProcessedRecords {
total_processed_input_records: self.status.num_total_processed_records(),
total_processed_steps: self.status.global_metrics.total_completed_steps(),
}));
let step = step.unwrap_or_else(|| {
processed_records
.as_ref()
Expand Down
Loading
Loading