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(sql-backend): integrate HummockManager with model V2 #14355

Merged
merged 10 commits into from
Jan 10, 2024

Conversation

zwang28
Copy link
Contributor

@zwang28 zwang28 commented Jan 4, 2024

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

What's changed and what's your intention?

This PR makes HummockManager support both metadata model V1 and model V2.

  • Add/Refactor macro create_trx_wrapper and commit_multi_var.
    • It can commit both V1 and V2. Whether to use V1 o r V2 depends on whether sql_meta_store is provided.
    • check_context is moved out of commit_multi_var, explicitly called in pin/unpin methods.
  • Add wrappers like BTreeMapTransactionWrapper, which dispatches requests to BTreeMapTransaction<V1> or BTreeMapTransaction<V2>.

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 changed the title feat(sql-backend): integrate Hummock with model V2 feat(sql-backend): integrate HummockManager with model V2 Jan 4, 2024
@zwang28 zwang28 requested review from wenym1 and yezizp2012 January 4, 2024 05:17
@zwang28 zwang28 marked this pull request as ready for review January 4, 2024 05:18
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! Thanks for the PR!

@@ -75,6 +76,8 @@ pub struct MetaSrvEnv {
/// Client to connector node. `None` if endpoint unspecified or unable to connect.
connector_client: Option<ConnectorClient>,

pub hummock_seq: Option<Arc<SequenceGenerator>>,
Copy link
Contributor

Choose a reason for hiding this comment

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

We can wrap the Option<Arc<SequenceGenerator>> as a struct HummockSequenceIdManager and provides method like fn next_compaction_task_id(&self).

@@ -659,7 +707,12 @@ impl HummockManager {
) -> Result<HummockSnapshot> {
let snapshot = self.latest_snapshot.load();
let mut guard = write_lock!(self, versioning).await;
let mut pinned_snapshots = BTreeMapTransaction::new(&mut guard.pinned_snapshots);
self.check_context_with_meta_node(context_id).await?;
Copy link
Contributor

Choose a reason for hiding this comment

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

Question: at the very beginning version of code, we atomically check the context id when we commit to meta store. Now we only check the context id before we do the transaction. Will it cause bug if the context id becomes invalid after we have checked it but before we commit it to meta store?

Copy link
Contributor Author

@zwang28 zwang28 Jan 10, 2024

Choose a reason for hiding this comment

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

As mentioned by the comments in check_context_with_meta_node, "Caller should hold versioning lock, to sync with HummockManager::release_contexts". By adhering to that rule, correctness is guaranteed, because all callers interested in context_id are executed sequentially.

It's OK context_id has become invalid when commit to meta store. What to prevent is, e.g. pin_version after release_contexts for a invalid context.

@zwang28 zwang28 added this pull request to the merge queue Jan 10, 2024
Merged via the queue into main with commit f3b0650 Jan 10, 2024
27 of 28 checks passed
@zwang28 zwang28 deleted the wangzheng/hummock_enable_v2 branch January 10, 2024 02:24
@zwang28 zwang28 mentioned this pull request Jan 15, 2024
9 tasks
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