-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
Define the placement of data by SQL statements #18030
Comments
@djshow832 How about changing the ALTER TABLE users ALTER PARTITION west
ADD PLACEMENT POLICY
LOCALITY="+zone=west_dc"
ROLE="leader"
REPLICAS=1; IMO, |
CockroachDB uses ALTER PARTITION chicago OF INDEX users@*
CONFIGURE ZONE USING
num_replicas = 3,
constraints = '{"+region=us-central":1}',
lease_preferences = '[[+region=us-central]]'; See https://www.cockroachlabs.com/docs/stable/topology-geo-partitioned-leaseholders.html for details. |
There's a problem for |
We use the following SQL command to add 2 tiflash replicas for table ALTER TABLE `tpch50`.`lineitem` SET TIFLASH REPLICA 2 Let's regard SQL commands as the user interface, In this issue, we need to design a SQL command for the user to place a partition of the table to a specific geographic position(Rack, AZ, Region, etc.). Although we are able to use this same SQL command to add TiFlash replicas, it's better not to do it this way. I prefer to use the specific SQL command to do the specific thing. |
I prefer to use |
So you mean, we do not support adding TiFlash replicas through the |
follow pingcap/tidb#18030 (comment). However, "constraints" is used for "label". Because it is not necessarily related to region/locality.
follow pingcap#18030 (comment). However, "constraints" is used for "label". Because it is not necessarily related to region/locality.
follow #18030 (comment). However, "constraints" is used for "label". Because it is not necessarily related to region/locality.
Description
TiDB supports placement rules, which can define the placement of data in a more flexible and more granular way. But it only provides configuration files to define them, and it’s complicated.
This issue tracks our progress in adding support via SQL.
The use cases for Placement Rules generally fit into two broad categories:
We are designing the syntax with both of these features in mind, but anticipate that initially use-case (1) will be better handled.
Sub Tasks
Named Placement Policy
(Previously: #26580 )
Support SHOW PLACEMENT
(Previously: #26582 )
SHOW PLACEMENT FOR [{DATABASE | SCHEMA} schema_name] [TABLE table_name] [PARTITION partition_name]
SHOW PLACEMENT LIKE
should return a list ofPLACEMENT POLICIES
that have been loaded in the TiDB server.SHOW PLACEMENT
for placement policies #27531SHOW PLACEMENT FOR
Add SHOW PLACEMENT FOR .. syntax #27976SHOW PLACEMENT
support for tables #28266SHOW PLACEMENT
support for DB #28366SHOW PLACEMENT
support for partitions #28830SHOW PLACEMENT
andSHOW PLACEMENT FOR
Add privilege checks for SHOW PLACEMENT FOR / LIKE #27977Information_schema
primaryRegion
andregions
toxxx_constraints
for convenience, refer Support information_schema.placement_rules #26681 (comment)Direct Placement Options / General Meta data
(Previously: #26581 )
parser: Support the following as table_options in
CREATE|ALTER TABLE
andCREATE|ALTER DATABASE
contexts. This should also work for partitions, such asALTER TABLE t PARTITION p0
.SHOW CREATE TABLE
but always enclosed in a version specific comment (/*T![placement]
). executor: Add support for placement inSHOW CREATE TABLE
#27792SHOW PLACEMENT LABELS
New Placement Rules Engine
(Previously: #27011 )
This is a sub-task of Placement Rules in SQL: #18030. Depends on #26580 and #26581. Once metadata has been finished, we need to add a new middle state to all related DDL jobs to sync rules to PD. Previous, we have already implemented similar code, so the work is more of a migration.
This requires the following subtasks:
Rule Removal
Others
TIDB_PLACEMENT_POLICY_NAME
andTIDB_DIRECT_PLACEMENT
to information_schema.schemata #29758tidb_enable_alter_placement
#31053tidb_placement_mode
#31092location_labels
be empty #31052SCHEDULE="majority_in_primary"
andPRIMARY_REGION
andREGIONS
are the same #31271Remove direct placement options
This is to track the changes required for #31423
SHOW CREATE TABLE
/SHOW CREATE DATABASE
. This should mean any existing installs upgrading will eventually lose their direct placement options. #31427Tools Behaviors
CreatePlacementPolicyWithInfo
to interfaceddl.DDL
to support br restore #32951Future work
We will plan for future delivery:
followers=0
syntax #31001The text was updated successfully, but these errors were encountered: