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

feat(streaming): recover no_shuffle_backfill #12493

Merged
merged 9 commits into from
Sep 26, 2023
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
3 changes: 1 addition & 2 deletions ci/scripts/run-backfill-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
# Hence keeping it in case we ever need to debug backfill again.

# USAGE:
# Start a rw cluster then run this script.
# ```sh
# ./risedev d
# cargo make ci-start ci-backfill
# ./ci/scripts/run-backfill-tests.sh
# ```

Expand Down
2 changes: 1 addition & 1 deletion ci/scripts/sql/backfill/insert.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ insert into t1
SELECT
generate_series,
'{"orders": {"id": 1, "price": "2.30", "customer_id": 2}}'::jsonb
FROM generate_series(1, 200000);
FROM generate_series(1, 100000);
FLUSH;
22 changes: 15 additions & 7 deletions src/meta/src/barrier/progress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ type ConsumedRows = u64;
enum ChainState {
Init,
ConsumingUpstream(Epoch, ConsumedRows),
Done,
Done(ConsumedRows),
}

/// Progress of all actors containing chain nodes while creating mview.
Expand Down Expand Up @@ -93,18 +93,19 @@ impl Progress {
match self.states.remove(&actor).unwrap() {
ChainState::Init => {}
ChainState::ConsumingUpstream(_, old_consumed_rows) => {
if !matches!(new_state, ChainState::Done) {
if !matches!(new_state, ChainState::Done(_)) {
self.consumed_rows -= old_consumed_rows;
}
}
ChainState::Done => panic!("should not report done multiple times"),
ChainState::Done(_) => panic!("should not report done multiple times"),
};
match &new_state {
ChainState::Init => {}
ChainState::ConsumingUpstream(_, new_consumed_rows) => {
self.consumed_rows += new_consumed_rows;
}
ChainState::Done => {
ChainState::Done(new_consumed_rows) => {
self.consumed_rows += new_consumed_rows;
self.done_count += 1;
}
};
Expand Down Expand Up @@ -281,14 +282,21 @@ impl CreateMviewProgressTracker {
) -> Option<TrackingCommand> {
let actor = progress.chain_actor_id;
let Some(epoch) = self.actor_map.get(&actor).copied() else {
panic!(
"no tracked progress for actor {}, is it already finished?",
// On restart, backfill will ALWAYS notify CreateMviewProgressTracker,
// even if backfill is finished on recovery.
// This is because we don't know if only this actor is finished,
// OR the entire stream job is finished.
// For the first case, we must notify meta.
// For the second case, we can still notify meta, but ignore it here.
tracing::info!(
"no tracked progress for actor {}, the stream job could already be finished",
actor
);
return None;
kwannoel marked this conversation as resolved.
Show resolved Hide resolved
};

let new_state = if progress.done {
ChainState::Done
ChainState::Done(progress.consumed_rows)
} else {
ChainState::ConsumingUpstream(progress.consumed_epoch.into(), progress.consumed_rows)
};
Expand Down
2 changes: 1 addition & 1 deletion src/stream/src/executor/backfill/arrangement_backfill.rs
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ where
&mut temporary_state,
).await?;

self.progress.finish(barrier.epoch.curr);
self.progress.finish(barrier.epoch.curr, total_snapshot_processed_rows);
yield msg;
break;
}
Expand Down
Loading
Loading