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: persist processed rows for SourceBackfill for SHOW JOBS #18983

Merged

Conversation

xxchan
Copy link
Member

@xxchan xxchan commented Oct 17, 2024

I hereby agree to the terms of the RisingWave Labs, Inc. Contributor License Agreement.

What's changed and what's your intention?

Follow up of #18925

If we don't persist, after recovery the progress will start from 0 again.

However, TBH I'm a little hesitant about this change, since it is a little ugly. And we have to persist it just for SHOW JOBS.


This changes the state table representation, and should be a breaking change. But if we can get this into 2.1, then we don't need to consider compatibility.


Besides SHOW JOBS, this also benefits scanning from state table, making it more informative. (See diff on slt)

Checklist

  • I have written necessary rustdoc comments
  • I have added necessary unit tests and integration tests
  • I have added test labels as necessary. See details.
  • I have added fuzzing tests or opened an issue to track them. (Optional, recommended for new SQL features Sqlsmith: Sql feature generation #7934).
  • My PR contains breaking changes. (If it deprecates some features, please create a tracking issue to remove them in the future).
  • All checks passed in ./risedev check (or alias, ./risedev c)
  • My PR changes performance-critical code. (Please run macro/micro-benchmarks and show the results.)
  • My PR contains critical fixes that are necessary to be merged into the latest release. (Please check out the details)

Documentation

  • My PR needs documentation updates. (Please use the Release note section below to summarize the impact on users)

Release note

If this PR includes changes that directly affect users or other significant modifications relevant to the community, kindly draft a release note to provide a concise summary of these changes. Please prioritize highlighting the impact these changes will have on users.

Copy link
Member Author

xxchan commented Oct 17, 2024

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @xxchan and the rest of your teammates on Graphite Graphite

@xxchan xxchan marked this pull request as ready for review October 17, 2024 15:44
@xxchan xxchan force-pushed the 10-17-feat_persist_processed_rows_for_sourcebackfill_for_show_jobs branch from 6436f64 to 1fa501c Compare October 17, 2024 15:45
Comment on lines 65 to 74
impl BackfillStateWithCnt {
pub fn encode_to_json(self) -> JsonbVal {
serde_json::to_value(self).unwrap().into()
}
Copy link
Member Author

@xxchan xxchan Oct 17, 2024

Choose a reason for hiding this comment

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

This changes the state table representation, and should be a breaking change. But if we can get this into 2.1, then we don't need to consider compatibility.

@@ -668,23 +682,15 @@ impl<S: StateStore> SourceBackfillExecutorInner<S> {
let new_chunk = chunk.clone_with_vis(new_vis);
yield Message::Chunk(new_chunk);
source_backfill_row_count.inc_by(card as u64);
total_backfilled_rows += card as u64;
Copy link
Member Author

@xxchan xxchan Oct 17, 2024

Choose a reason for hiding this comment

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

Previously, we just need to += card here for total cnt

@@ -206,6 +216,8 @@ impl BackfillStage {
/// Updates backfill states and returns whether the row backfilled from external system is visible.
fn handle_backfill_row(&mut self, split_id: &str, offset: &str) -> bool {
let state = self.states.get_mut(split_id).unwrap();
state.num_consumed_rows += 1;
Copy link
Member Author

Choose a reason for hiding this comment

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

Now we need to +=1 since we need to count and persist separately for each split.

@xxchan xxchan force-pushed the 09-06-feat_improve_progress_msg_for_source_backfill branch from c9d083b to 16ae682 Compare October 17, 2024 15:55
@xxchan xxchan force-pushed the 10-17-feat_persist_processed_rows_for_sourcebackfill_for_show_jobs branch 2 times, most recently from 7c2e849 to e6086ef Compare October 17, 2024 15:57
Comment on lines 601 to 614
total_backfilled_rows,
backfill_stage.total_backfilled_rows(),
Copy link
Member Author

Choose a reason for hiding this comment

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

Now we calculate per-split cnt, and sum here

@xxchan xxchan force-pushed the 09-06-feat_improve_progress_msg_for_source_backfill branch from 16ae682 to 3498778 Compare October 18, 2024 00:16
@xxchan xxchan force-pushed the 10-17-feat_persist_processed_rows_for_sourcebackfill_for_show_jobs branch from e6086ef to 09a9737 Compare October 18, 2024 00:16
@xxchan xxchan force-pushed the 09-06-feat_improve_progress_msg_for_source_backfill branch from 3498778 to 4a18292 Compare October 18, 2024 00:40
@xxchan xxchan force-pushed the 10-17-feat_persist_processed_rows_for_sourcebackfill_for_show_jobs branch from 09a9737 to 7fa4f3f Compare October 18, 2024 00:40
@xxchan xxchan force-pushed the 09-06-feat_improve_progress_msg_for_source_backfill branch from 4a18292 to 1c50a1b Compare October 18, 2024 03:15
@xxchan xxchan force-pushed the 10-17-feat_persist_processed_rows_for_sourcebackfill_for_show_jobs branch from 7fa4f3f to b08b8af Compare October 18, 2024 03:16
@xxchan xxchan force-pushed the 09-06-feat_improve_progress_msg_for_source_backfill branch from 1c50a1b to eaa34e4 Compare October 18, 2024 07:04
@xxchan xxchan force-pushed the 10-17-feat_persist_processed_rows_for_sourcebackfill_for_show_jobs branch from b08b8af to ef793bd Compare October 18, 2024 07:04
@xxchan xxchan force-pushed the 09-06-feat_improve_progress_msg_for_source_backfill branch from eaa34e4 to 0f6248b Compare October 18, 2024 07:27
@xxchan xxchan force-pushed the 10-17-feat_persist_processed_rows_for_sourcebackfill_for_show_jobs branch 2 times, most recently from 45f6490 to 874ca44 Compare October 18, 2024 07:33
@BugenZhao
Copy link
Member

And we have to persist it just for SHOW JOBS.

You mean it's just for observability/debugging purposes?

@xxchan
Copy link
Member Author

xxchan commented Oct 18, 2024

And we have to persist it just for SHOW JOBS.

You mean it's just for observability/debugging purposes?

Yes.

@xxchan
Copy link
Member Author

xxchan commented Oct 21, 2024

Hey @BugenZhao @kwannoel , would you mind taking a look at the downstack PR #18925? 🤣

@xxchan xxchan force-pushed the 09-06-feat_improve_progress_msg_for_source_backfill branch from 7d123f2 to d3ef9bb Compare October 21, 2024 01:47
@xxchan xxchan force-pushed the 10-17-feat_persist_processed_rows_for_sourcebackfill_for_show_jobs branch from 874ca44 to f0130cd Compare October 21, 2024 01:47
Comment on lines +37 to +39
2 {"v1": 3, "v2": "c"}
3 {"v1": 4, "v2": "d"}
3 {"v1": 4, "v2": "d"}
Copy link
Member Author

Choose a reason for hiding this comment

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

produce more data to make partitions look different

@xxchan
Copy link
Member Author

xxchan commented Oct 21, 2024

Inspired by #18925 (comment), I also persist target_offset in state table to make selecting from state table more informative. (SHOW JOBS is not affected)

👍 if it looks good @BugenZhao @kwannoel 👀

@xxchan
Copy link
Member Author

xxchan commented Oct 21, 2024

BTW, I just realized that we can merge this PR first, not necessarily wait for #18925

0,"{""num_consumed_rows"": 0, ""state"": ""Finished"", ""target_offset"": null}"
1,"{""num_consumed_rows"": 0, ""state"": ""Finished"", ""target_offset"": null}"
2,"{""num_consumed_rows"": 0, ""state"": ""Finished"", ""target_offset"": null}"
3,"{""num_consumed_rows"": 0, ""state"": ""Finished"", ""target_offset"": null}"
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like we don't have any tests to check the output of show jobs?

Copy link
Member Author

@xxchan xxchan Oct 21, 2024

Choose a reason for hiding this comment

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

The DDL finishes immediately. It seems not easy to test show jobs (and it has non deterministic results).

@kwannoel
Copy link
Contributor

Actually do we still need to persist backfilled rows? Since we can just use offset to show progress.

@xxchan
Copy link
Member Author

xxchan commented Oct 21, 2024

Actually do we still need to persist backfilled rows? Since we can just use offset to show progress.

I'm thinking num_backfilled_rows is still valuable now, which provides a different dimension of information as offsets.
See #18925 (comment)

How do you think?

@xxchan
Copy link
Member Author

xxchan commented Oct 21, 2024

We may also deprecate some fields in the future if they are not useful.

@xxchan xxchan force-pushed the 10-17-feat_persist_processed_rows_for_sourcebackfill_for_show_jobs branch from f7949f1 to 4d00aac Compare October 21, 2024 08:48
@xxchan xxchan changed the base branch from 09-06-feat_improve_progress_msg_for_source_backfill to main October 21, 2024 08:48
Signed-off-by: xxchan <[email protected]>
@xxchan xxchan enabled auto-merge October 21, 2024 08:57
@xxchan xxchan added this pull request to the merge queue Oct 21, 2024
@graphite-app graphite-app bot requested a review from a team October 21, 2024 09:36
Merged via the queue into main with commit 3e7fffd Oct 21, 2024
30 of 31 checks passed
@xxchan xxchan deleted the 10-17-feat_persist_processed_rows_for_sourcebackfill_for_show_jobs branch October 21, 2024 10:02
github-actions bot pushed a commit that referenced this pull request Oct 21, 2024
github-merge-queue bot pushed a commit that referenced this pull request Oct 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants