Skip to content

Refactor cluster manager on client#95

Merged
lzxddz merged 4 commits intoremove-mutexfrom
refactor-client-config
Sep 30, 2025
Merged

Refactor cluster manager on client#95
lzxddz merged 4 commits intoremove-mutexfrom
refactor-client-config

Conversation

@lzxddz
Copy link
Copy Markdown
Collaborator

@lzxddz lzxddz commented Sep 26, 2025

Use these data structures to store the cluster info at DataStoreServiceClient :

 struct DssNode
    {
        std::string host_name_;
        uint16_t port_;
        brpc::Channel channel_;

        // expired_ts_ is the timestamp when the node is expired.
        // If expired_ts_ is 0, the node is not expired.
        // If expired_ts_ is not 0, the node is expired and the value is the
        // timestamp when the node is expired.
        std::atomic<uint64_t> expired_ts_{1U};
    };
    // Cached nodes info of data store service.
    std::vector<DssNode> dss_nodes_{1024};
    // Now only support one shard. dss_shards_ caches the index in dss_nodes_ of
    // shard owner.
    std::vector<std::atomic<uint32_t>> dss_shards_{1, UINT32_MAX};
    const uint64_t NodeExpiredTime = 10 * 1000 * 1000;  // 10s

dss_nodes_ caches node info that used by dss_shards_.

When update the owner of data shard or update the channel of node, we firstly update the expired_ts_ of old node.
Then, find a free node index in dss_nodes_ (the expiration time exceeds 10 seconds or expired_ts_ is 1 ).
After updated the info at free node index, change the value of shard in dss_shards_.

To avoid using mutex lock, we must promise the dss_nodes_ should not be resized. If we can not find a free node index, we should wait and retry.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Sep 26, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch refactor-client-config

Comment @coderabbitai help to get the list of available commands and usage tips.

@lzxddz lzxddz linked an issue Sep 26, 2025 that may be closed by this pull request
Copy link
Copy Markdown
Collaborator

@githubzilla githubzilla left a comment

Choose a reason for hiding this comment

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

LGTM

@lzxddz lzxddz merged commit 57d1ffc into remove-mutex Sep 30, 2025
1 check passed
lzxddz added a commit that referenced this pull request Oct 13, 2025
* Update cluster config in client

* fix datastore migration error
lzxddz added a commit that referenced this pull request Oct 14, 2025
* Remove lock serv_mux_

Change DataStoreService: only contain one data shard in one DataStoreService.

Create DataStore in DataStoreService instead in eloqsql or eloqkv server.

Remove ongoing_write_requests_ from RocksDBDataStoreCommon and let DataStoreService manage ongoing_write_requests_.


* Refactor cluster manager on client (#95)
Use a non-lock struct to manage data shards info.
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.

Refactor the use of cluster manger in data store service and client

2 participants