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

fix(meta): use per table mce and safe epoch in metadata backup #17227

Merged
merged 5 commits into from
Jun 13, 2024

Conversation

zwang28
Copy link
Contributor

@zwang28 zwang28 commented Jun 12, 2024

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

What's changed and what's your intention?

After #17161, batch query over metadata backup won't work correctly, because it try_get_hummock_version (find a queryable backup) using global safe_epoch and MCE, while validate_safe_epoch using per table safe_epoch and MCE.

This PR fixes it by storing and using per table safe_epoch and MCE.

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.

@zwang28 zwang28 requested a review from wenym1 June 12, 2024 15:40
@github-actions github-actions bot added the type/fix Bug fix label Jun 12, 2024
@zwang28 zwang28 enabled auto-merge June 12, 2024 15:41
# Conflicts:
#	proto/backup_service.proto
#	src/storage/backup/src/lib.rs
@zwang28 zwang28 disabled auto-merge June 13, 2024 04:11
@zwang28
Copy link
Contributor Author

zwang28 commented Jun 13, 2024

FYI, I have to revert the adoption of the macro introduced in #17225 when restoring a backup, because insertion requires a specific order to satisfy foreign key constraints, which is different with the one in for_all_metadata_models_v2. @yezizp2012

That means, now to include a new model in metadata backup, 2 steps are required:

  1. Add it at the end of for_all_metadata_models_v2, so that it's included in backup.
  2. Add another insert_model for it in the appropriate place, ensuring that all FK constraints are satisfied.

@zwang28 zwang28 enabled auto-merge June 13, 2024 06:02
@zwang28 zwang28 disabled auto-merge June 13, 2024 06:07
@zwang28 zwang28 enabled auto-merge June 13, 2024 06:30
Copy link
Contributor

@wenym1 wenym1 left a comment

Choose a reason for hiding this comment

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

Rest LGTM

@@ -58,6 +60,8 @@ pub struct MetaSnapshotMetadata {
#[serde(default)]
pub format_version: u32,
pub remarks: Option<String>,
#[serde(with = "table_id_key_map")]
Copy link
Contributor

Choose a reason for hiding this comment

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

If we set key type as string or u32, we may not need to impl the serde by ourselves?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

serde_json requires map key to be String. So either using String as key or impl the serde.

The downside of using String as key is additional type conversion when visiting the map.

#[async_trait::async_trait]
impl Writer<MetadataV2> for WriterModelV2ToMetaStoreV2 {
async fn write(&self, target_snapshot: MetaSnapshot<MetadataV2>) -> BackupResult<()> {
let metadata = target_snapshot.metadata;
let db = &self.meta_store.conn;
write_model_v2_to_meta_store_v2(&metadata, db).await?;
insert_models(metadata.seaql_migrations.clone(), db).await?;
Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason to manually expand the macro here?

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh I saw the comment now.

Copy link
Contributor

@wenym1 wenym1 left a comment

Choose a reason for hiding this comment

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

LGTM

@zwang28 zwang28 added this pull request to the merge queue Jun 13, 2024
Merged via the queue into main with commit 3b823d0 Jun 13, 2024
32 of 33 checks passed
@zwang28 zwang28 deleted the wangzheng/fix_query_backup branch June 13, 2024 08:18
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.

2 participants