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: adding column of table schema change #8063

Merged
merged 25 commits into from Feb 27, 2023
Merged

Conversation

BugenZhao
Copy link
Member

@BugenZhao BugenZhao commented Feb 20, 2023

Signed-off-by: Bugen Zhao i@bugenzhao.com
I hereby agree to the terms of the RisingWave Labs, Inc. Contributor License Agreement.

What's changed and what's your intention?

This PR implements adding columns of table schema change on the meta service and compute node.

Note: this PR should not be marked as user-facing, until #7906 is done.

Tracking issue: #6903.
Close #7908. Close #7910.

Checklist

  • I have written necessary rustdoc comments
  • I have added necessary unit tests and integration tests
  • All checks passed in ./risedev check (or alias, ./risedev c)

Documentation

  • My PR DOES NOT contain user-facing changes.
Click here for Documentation

Types of user-facing changes

Please keep the types that apply to your changes, and remove the others.

  • Installation and deployment
  • Connector (sources & sinks)
  • SQL commands, functions, and operators
  • RisingWave cluster configuration changes
  • Other (please specify in the release note below)

Release note

Signed-off-by: Bugen Zhao <i@bugenzhao.com>
Signed-off-by: Bugen Zhao <i@bugenzhao.com>
Signed-off-by: Bugen Zhao <i@bugenzhao.com>
Signed-off-by: Bugen Zhao <i@bugenzhao.com>
Signed-off-by: Bugen Zhao <i@bugenzhao.com>
Signed-off-by: Bugen Zhao <i@bugenzhao.com>
Signed-off-by: Bugen Zhao <i@bugenzhao.com>
Signed-off-by: Bugen Zhao <i@bugenzhao.com>
@BugenZhao BugenZhao changed the title feat: adding column of table schema change feat: adding column of table schema change [WIP] Feb 20, 2023
@github-actions github-actions bot added type/feature user-facing-changes Contains changes that are visible to users labels Feb 20, 2023
mergify bot pushed a commit that referenced this pull request Feb 23, 2023
This PR moves the `ColIndexMapping` utility from the frontend crate to the common crate, since the meta service will also rely on this (#8063). The frontend-specific methods are provided by an extension trait.

Approved-By: st1page
Approved-By: xxchan
…-part-2

Signed-off-by: Bugen Zhao <i@bugenzhao.com>
Signed-off-by: Bugen Zhao <i@bugenzhao.com>
Signed-off-by: Bugen Zhao <i@bugenzhao.com>
Signed-off-by: Bugen Zhao <i@bugenzhao.com>
Signed-off-by: Bugen Zhao <i@bugenzhao.com>
Signed-off-by: Bugen Zhao <i@bugenzhao.com>
Signed-off-by: Bugen Zhao <i@bugenzhao.com>
Signed-off-by: Bugen Zhao <i@bugenzhao.com>
@github-actions github-actions bot removed the user-facing-changes Contains changes that are visible to users label Feb 24, 2023
@BugenZhao BugenZhao changed the title feat: adding column of table schema change [WIP] feat: adding column of table schema change Feb 24, 2023
@BugenZhao BugenZhao marked this pull request as ready for review February 24, 2023 10:42

table_fragments.insert(table_id, table_fragment.clone());

// Update downstream `Merge`s.
Copy link
Member Author

Choose a reason for hiding this comment

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

This part is too dirty. 🥵

@@ -842,18 +924,26 @@ where
pub async fn get_downstream_chain_fragments(
&self,
table_id: TableId,
) -> MetaResult<Vec<Fragment>> {
) -> MetaResult<Vec<(DispatchStrategy, Fragment)>> {
Copy link
Member Author

Choose a reason for hiding this comment

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

We also need the output indices in the dispatchers (then map it with column index mapping), so Fragment is not sufficient here.

let added_upstream_actor_id = update.added_upstream_actor_id.clone();
let removed_upstream_actor_id: HashSet<_> =
if update.new_upstream_fragment_id.is_some() {
select_all.upstream_actor_ids().iter().copied().collect()
Copy link
Member Author

Choose a reason for hiding this comment

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

Remove all actors if fragment id is changed.

// - For scaling, this is always `None`.
// - For plan change, the upstream fragment will be changed to a new one, and this will be `Some`.
// In this case, all the upstream actors should be removed and replaced by the `new` ones.
optional uint32 new_upstream_fragment_id = 5;

@codecov
Copy link

codecov bot commented Feb 24, 2023

Codecov Report

Merging #8063 (7bb5515) into main (6ed9f48) will decrease coverage by 0.11%.
The diff coverage is 13.83%.

@@            Coverage Diff             @@
##             main    #8063      +/-   ##
==========================================
- Coverage   71.70%   71.59%   -0.11%     
==========================================
  Files        1131     1131              
  Lines      182325   182672     +347     
==========================================
+ Hits       130731   130780      +49     
- Misses      51594    51892     +298     
Flag Coverage Δ
rust 71.59% <13.83%> (-0.11%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/common/src/util/column_index_mapping.rs 72.19% <0.00%> (-13.80%) ⬇️
src/frontend/src/catalog/catalog_service.rs 5.55% <0.00%> (-0.33%) ⬇️
src/meta/src/barrier/command.rs 36.80% <0.00%> (-3.26%) ⬇️
src/meta/src/barrier/schedule.rs 63.63% <0.00%> (-1.40%) ⬇️
src/meta/src/manager/catalog/database.rs 41.25% <0.00%> (-0.53%) ⬇️
src/meta/src/manager/catalog/fragment.rs 26.78% <0.00%> (-3.74%) ⬇️
src/meta/src/manager/catalog/mod.rs 31.68% <0.00%> (-1.15%) ⬇️
src/meta/src/model/stream.rs 72.35% <0.00%> (-0.75%) ⬇️
src/meta/src/rpc/ddl_controller.rs 0.00% <0.00%> (ø)
src/meta/src/rpc/service/ddl_service.rs 0.00% <0.00%> (ø)
... and 17 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Contributor

@yezizp2012 yezizp2012 left a comment

Choose a reason for hiding this comment

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

LSTM!!! Except some workaround, we can refactor them later. 🥵

src/meta/src/manager/catalog/mod.rs Outdated Show resolved Hide resolved
src/meta/src/rpc/service/ddl_service.rs Outdated Show resolved Hide resolved
Comment on lines +346 to +349
self.notify_fragment_mapping(&old_table_fragment, Operation::Delete)
.await;
self.notify_fragment_mapping(&table_fragment, Operation::Add)
.await;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this 2 lines be merged into 1 Update?

Copy link
Member Author

Choose a reason for hiding this comment

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

I guess we can't. By specifying Update we will update the vnode mapping for all fragment in the list that is used for scaling, while in this case, the fragment list is replaced and we should delete the entry of vnode mapping for old fragments.

…-part-2

Signed-off-by: Bugen Zhao <i@bugenzhao.com>
Signed-off-by: Bugen Zhao <i@bugenzhao.com>
Signed-off-by: Bugen Zhao <i@bugenzhao.com>
@BugenZhao BugenZhao added this pull request to the merge queue Feb 27, 2023
Merged via the queue into main with commit 85646ba Feb 27, 2023
@BugenZhao BugenZhao deleted the bz/schema-change-meta-part-2 branch February 27, 2023 16:50
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.

Integrate ADD COLUMN on the frontend with meta service. Implement replacing table plan in meta service.
3 participants