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

Show placement information in SHOW TABLE x REGIONS #32458

Closed
Tracked by #18030
morgo opened this issue Feb 18, 2022 · 4 comments · Fixed by #35202
Closed
Tracked by #18030

Show placement information in SHOW TABLE x REGIONS #32458

morgo opened this issue Feb 18, 2022 · 4 comments · Fixed by #35202
Assignees
Labels
help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. type/feature-request Categorizes issue or PR as related to a new feature.

Comments

@morgo
Copy link
Contributor

morgo commented Feb 18, 2022

Placement rules are by design asyncronously scheduled. The state of scheduling can be observed in the statement SHOW PLACEMENT FOR.

This is a feature request to also include current placement information in the statement SHOW TABLE x REGIONS. The motivation for doing this is as follows:

  • It allows observability of the current scheduling state (show placement for is too binary). Consider this as similar to how we can observe the progress of DDL
  • It allows for verification that the rules are in fact followed correctly. We can incorporate this into our own scenario testing, but also for users that have compliance or HA requirements they might script against it to verify correctness.

The current output of SHOW TABLE x REGIONS is as follows:

tidb> show table t1 regions;
+-----------+---------------+---------------+-----------+-----------------+-------+------------+---------------+------------+----------------------+------------------+
| REGION_ID | START_KEY     | END_KEY       | LEADER_ID | LEADER_STORE_ID | PEERS | SCATTERING | WRITTEN_BYTES | READ_BYTES | APPROXIMATE_SIZE(MB) | APPROXIMATE_KEYS |
+-----------+---------------+---------------+-----------+-----------------+-------+------------+---------------+------------+----------------------+------------------+
|         4 |               | t_63_r_89565  |         5 |               1 | 5     |          0 |          4337 |      80007 |                  107 |           367623 |
|         6 | t_63_r_89565  | t_63_r_179845 |         7 |               1 | 7     |          0 |          1323 |   12187800 |                   91 |                0 |
|         8 | t_63_r_179845 | t_63_r_270126 |         9 |               1 | 9     |          0 |          1323 |   12187935 |                  102 |           115360 |
|        10 | t_63_r_270126 | t_63_r_360407 |        11 |               1 | 11    |          0 |            27 |   12187935 |                   91 |            63475 |
|        12 | t_63_r_360407 | t_63_r_450687 |        13 |               1 | 13    |          0 |          1323 |   12187800 |                  122 |           566573 |
|        14 | t_63_r_450687 | t_63_r_540968 |        15 |               1 | 15    |          0 |          1323 |    8125290 |                   95 |            57600 |
|        16 | t_63_r_540968 | t_63_r_631248 |        17 |               1 | 17    |          0 |          1323 |          0 |                  109 |           207822 |
|         2 | t_63_r_631248 |               |         3 |               1 | 3     |          0 |          1498 |          0 |                  103 |           104284 |
+-----------+---------------+---------------+-----------+-----------------+-------+------------+---------------+------------+----------------------+------------------+
8 rows in set (0.01 sec)

I propose that we add 2 columns:

  • Scheduling Constraints: a list of recorded constraints for the region. It can be json formatted.
  • Scheduling State: the same output as from SHOW PLACEMENT FOR.
@morgo morgo added type/feature-request Categorizes issue or PR as related to a new feature. help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. labels Feb 18, 2022
@johnhaxx7
Copy link
Contributor

Hi @morgo, I'm pretty interested in this task, but I have no idea of the complexity and effort, or any dependency for this.
If it's ok for me to take this, any chance you can give a brief walkthrough so that I can make sure things are on track?
I'm at PST timezone, a short chat on Slack would be great!

@morgo
Copy link
Contributor Author

morgo commented Jun 3, 2022

Hi @morgo, I'm pretty interested in this task, but I have no idea of the complexity and effort, or any dependency for this. If it's ok for me to take this, any chance you can give a brief walkthrough so that I can make sure things are on track? I'm at PST timezone, a short chat on Slack would be great!

Sure, you can find me on TiDB Community Slack :-)

The code for show placement is in ./executor/show_placement.go (copy this for how to get placement info). show table regions is in ./executor/show.go. The columns are defined here:

func buildTableRegionsSchema() (*expression.Schema, types.NameSlice) {
schema := newColumnsWithNames(11)
schema.Append(buildColumnWithName("", "REGION_ID", mysql.TypeLonglong, 4))
schema.Append(buildColumnWithName("", "START_KEY", mysql.TypeVarchar, 64))
schema.Append(buildColumnWithName("", "END_KEY", mysql.TypeVarchar, 64))
schema.Append(buildColumnWithName("", "LEADER_ID", mysql.TypeLonglong, 4))
schema.Append(buildColumnWithName("", "LEADER_STORE_ID", mysql.TypeLonglong, 4))
schema.Append(buildColumnWithName("", "PEERS", mysql.TypeVarchar, 64))
schema.Append(buildColumnWithName("", "SCATTERING", mysql.TypeTiny, 1))
schema.Append(buildColumnWithName("", "WRITTEN_BYTES", mysql.TypeLonglong, 4))
schema.Append(buildColumnWithName("", "READ_BYTES", mysql.TypeLonglong, 4))
schema.Append(buildColumnWithName("", "APPROXIMATE_SIZE(MB)", mysql.TypeLonglong, 4))
schema.Append(buildColumnWithName("", "APPROXIMATE_KEYS", mysql.TypeLonglong, 4))
return schema.col2Schema(), schema.names

Try getting started, and if you get stuck I can check out your branch and take a look.

@johnhaxx7
Copy link
Contributor

Thank you Morgan! Assign per offline discussion

@johnhaxx7
Copy link
Contributor

/assign

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. type/feature-request Categorizes issue or PR as related to a new feature.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants