-
Notifications
You must be signed in to change notification settings - Fork 409
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
support keyspace feature #6816
support keyspace feature #6816
Conversation
[REVIEW NOTIFICATION] This pull request has been approved by:
To complete the pull request process, please ask the reviewers in the list to review by filling The full list of commands accepted by this bot can be found here. Reviewer can indicate their review by submitting an approval review. |
storages.emplace(table_id, storage); | ||
storages.emplace(keyspace_table_id, storage); | ||
auto [it, _] = keyspaces.try_emplace(keyspace_id, 0); | ||
it->second++; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this counter used for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I get it.
// If the table_info_json has no keyspace id, we use the keyspace_id_ as the default value. | ||
if (keyspace_id == NullspaceID) | ||
{ | ||
keyspace_id = keyspace_id_; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not always set keyspace_id = keyspace_Id_
? Is there any case that you will create a TableInfo without passing a valid keyspace_id_
when using api_v2?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sense, this logic intends to use the original keyspace id if the JSON object parameter has a keyspace id field. But this might useless since there is no keyspace id in the upstream table schema.
@@ -40,35 +40,42 @@ SchemaSyncService::SchemaSyncService(DB::Context & context_) | |||
handle = background_pool.addTask( | |||
[&, this] { | |||
String stage; | |||
auto keyspaces = context.getTMTContext().getStorages().getAllKeyspaces(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it contain NullspaceID
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it will contain Nullspace
.
} | ||
catch (const std::exception & e) | ||
{ | ||
LOG_ERROR(log, "{} failed by {}", stage, e.what()); | ||
LOG_ERROR(log, "[keyspace {}] {} failed by {}", cur_ks, stage, e.what()); | ||
} | ||
return false; | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's better make the task running interval be configurable.
next_table_id = iter->first; | ||
LOG_DEBUG(log, "End GC and next gc will start with table id: {}", next_table_id); | ||
|
||
if (iter != storages.end()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This if statement always be true, this line check seems useless.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This statement will be false if there is no storage to GC, for example, the TiFlash instance just starts up and there is no schema syncing happening before it receives some r/w request. Otherwise, an undefined value will be logged.
auto * log = &Poco::Logger::get("HandleHttpRequestSyncStatus"); | ||
LOG_DEBUG(log, "handling sync status request, path: {}, api_name: {}", path, api_name); | ||
|
||
// Query schema: /keyspace/{keyspace_id}/table/{table_id} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we keep the old query schema without keyspace?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the TiFlash replica status might be uncheckable in the rolling upgrade, we support the old schema.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly LGTM, please create the PRs to client-c and kvproto
@JaySon-Huang all comments have been addressed, PTAL. ❤️ The |
/rebuild |
The client-c hash is not updated to 04d408143e5ceb01799ec642560c39dc1a0a373f |
why the tiflash-proxy hash is updated? |
This has been done. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
/merge |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
/merge |
This comment was marked as outdated.
This comment was marked as outdated.
pending for pingcap/kvproto#1076 |
Signed-off-by: JaySon-Huang <tshent@qq.com>
/merge |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
Signed-off-by: iosmanthus <myosmanthustree@gmail.com>
Signed-off-by: JaySon-Huang <tshent@qq.com>
/merge |
@JaySon-Huang: It seems you want to merge this PR, I will help you trigger all the tests: /run-all-tests You only need to trigger If you have any questions about the PR merge process, please refer to pr process. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository. |
This pull request has been accepted and is ready to merge. Commit hash: a25cb09
|
/merge |
@iosmanthus: It seems you want to merge this PR, I will help you trigger all the tests: /run-all-tests You only need to trigger If you have any questions about the PR merge process, please refer to pr process. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository. |
@iosmanthus: In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository. |
Signed-off-by: iosmanthus myosmanthustree@gmail.com
What problem does this PR solve?
Issue Number: close #6815
TiKV API v2: https://tikv.org/docs/dev/concepts/explore-tikv-features/api-v2/
Problem Summary:
Deps:
What is changed and how it works?
This pull request separates each keyspace's db/tables by rewriting their name with a keyspace prefix.
For example, table 1 in keyspace 2 is stored in a directory named:
ks_2_t_1
, and the same as the schema SQL file.The keyspace's information is decoded from the region range in the writing process, and from gRPC requests context in the reading process. Every time TiFlash
syncSchema
, it needs a keyspace id parameter. The persistent schema will also contain the keyspace id in case of restarting the server.This pull request also introduces a new config named
api-version
, whose default value is 1 meaning the node is working in the legacy mode. In this mode, schema info will be fetched in the bootstrap stage. If theapi-version
is 2, then the node is working in the keyspace mode, which will fetch schema lazily.The pull request does not support the PageStoreV3 format and needs to be tested in V2 for now. In the future, the pull request should be compatible with the
UniversalPageStore
feature.Check List
Tests
Side effects
Documentation
Release note