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(remote_wal): add skeleton for remote wal related to meta srv #2933

Merged
merged 45 commits into from
Dec 19, 2023

Conversation

niebayes
Copy link
Contributor

@niebayes niebayes commented Dec 14, 2023

I hereby agree to the terms of the GreptimeDB CLA

What's changed and what's your intention?

The remote wal project involves modifying a bunch of codes and I've observed that reviewers are finding it challenging to grasp the overall scope of the remote wal project. This PR is proposed to try to speed up the review process.

Details

  • We are designing a WalOptions that stores wal options allocated at the granularity of a region.

  • We are designing a WalOptionsAllocator for the granular allocation of wal options based on regions. It internally maintains a KafkaTopicManager for allocating Kafka wal topics if the allocator is of type WalOptionsAllocator::Kafka. For efficiency, this allocator also supports batch allocation of wal options.

  • The KafkaTopicManager primarily consists of a topic pool and a topic selector.

    • During the initialization of the topic manager, we first read all already created topics from the kv backend. If there aren't enough topics created, we use the rskafka client to request creating more topics from the Kafka cluster. The names of the created topics are stored in the kv backend to avoid duplicate creation upon restart. These topic names are also cached in the in-memory topic pool.
    • The topic selector is responsible for selecting a topic from the topic pool based on a certain strategy (e.g., default round-robin).
  • When the Meta srv starts, we initialize the WalOptionsAllocator. It is then maintained by the TableMetadataAllocator in the DdlManager.

  • When handling a create table request, the create interface of the TableMetadataAllocator in the DdlManager is called. At this point, we invoke the WalOptionsAllocator to allocate wal options for each region of the table. The allocated wal options are passed to the procedure manager and used during the execution of the create table operation.

  • We modify DatanodeTableValue to include a wal_options_map field, of type HashMap<RegionNumber, EncodedWalOptions>, representing the wal options allocated for each region of a table. When persisting the metadata of a table, the procedure manager also persists the wal options. The EncodedWalOptions is simply a string.

  • When the Datanode starts, it reads the persisted DatanodeTableValue from the kv backend, retrieves the wal_options_map, decodes and extracts the wal options for each region. These wal options are stored in RegionOpenRequest for use when opening a region.

image

Checklist

  • I have written the necessary rustdoc comments.
  • I have added the necessary unit tests and integration tests.

Refer to a related PR or issue link (optional)

@niebayes niebayes marked this pull request as draft December 14, 2023 07:01
@niebayes niebayes self-assigned this Dec 14, 2023
@niebayes niebayes marked this pull request as ready for review December 14, 2023 07:47
Copy link

codecov bot commented Dec 14, 2023

Codecov Report

Merging #2933 (d8ef9bc) into develop (9af9c02) will increase coverage by 0.67%.
Report is 12 commits behind head on develop.
The diff coverage is 84.64%.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #2933      +/-   ##
===========================================
+ Coverage    85.12%   85.79%   +0.67%     
===========================================
  Files          756      767      +11     
  Lines       120101   123627    +3526     
===========================================
+ Hits        102232   106065    +3833     
+ Misses       17869    17562     -307     

@niebayes niebayes marked this pull request as draft December 15, 2023 06:40
config/metasrv.example.toml Outdated Show resolved Hide resolved
src/cmd/src/cli/bench/metadata.rs Outdated Show resolved Hide resolved
src/common/meta/src/key/datanode_table.rs Show resolved Hide resolved
src/common/meta/src/wal.rs Outdated Show resolved Hide resolved
src/common/meta/src/wal.rs Outdated Show resolved Hide resolved
src/common/meta/src/wal/kafka.rs Outdated Show resolved Hide resolved
src/common/meta/src/wal/kafka/topic.rs Outdated Show resolved Hide resolved
src/common/meta/src/wal/kafka.rs Show resolved Hide resolved
src/common/meta/src/wal/kafka/topic_manager.rs Outdated Show resolved Hide resolved
@niebayes niebayes requested a review from WenyXu December 19, 2023 06:35
Copy link
Member

@WenyXu WenyXu 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

config/metasrv.example.toml Outdated Show resolved Hide resolved
@niebayes niebayes added this pull request to the merge queue Dec 19, 2023
@niebayes niebayes removed this pull request from the merge queue due to a manual request Dec 19, 2023
config/metasrv.example.toml Show resolved Hide resolved
src/common/meta/src/instruction.rs Show resolved Hide resolved
src/common/meta/src/key/datanode_table.rs Show resolved Hide resolved
src/common/meta/src/key/datanode_table.rs Outdated Show resolved Hide resolved
src/common/meta/src/wal.rs Outdated Show resolved Hide resolved
src/common/meta/src/wal/options_allocator.rs Show resolved Hide resolved
src/frontend/src/instance/standalone.rs Outdated Show resolved Hide resolved
src/meta-srv/src/metasrv/builder.rs Outdated Show resolved Hide resolved
src/meta-srv/src/table_meta_alloc.rs Show resolved Hide resolved
@niebayes niebayes force-pushed the feat/remote_wal_skeleton_meta_srv branch from bf2e93d to cd1afdd Compare December 19, 2023 09:07
@niebayes niebayes requested a review from killme2008 December 19, 2023 12:08
@killme2008 killme2008 enabled auto-merge December 19, 2023 12:36
@killme2008 killme2008 added this pull request to the merge queue Dec 19, 2023
Merged via the queue into develop with commit 839e653 Dec 19, 2023
20 checks passed
@killme2008 killme2008 deleted the feat/remote_wal_skeleton_meta_srv branch December 19, 2023 12:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants