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

pdctl: fix region key problems in detach mode #1298

Merged
merged 3 commits into from
Oct 26, 2018
Merged

Conversation

rleungx
Copy link
Member

@rleungx rleungx commented Oct 26, 2018

What problem does this PR solve?

Currently, pd-ctl doesn't support using --format in detach mode and also can not decode the key which contains some escape characters, such as \n.

What is changed and how it works?

This PR fixes this two problems. After this PR, we need to wrap the key with single quotes ' in pd-ctl.
For example, we can use the below command to find the region for a given key:

./pd-ctl -d -u http://127.0.0.1:2379 region key --format=encode 't\200\000\000\000\000\000\000\377\035_r\200\000\000\000\000\377\017U\320\000\000\000\000\000 \372\n'

Check List

Tests

  • Manual test

Related changes

  • Need to cherry-pick to the release branch
  • Need to update the documentation
  • Need to be included in the release notes

@rleungx rleungx added the type/bug The issue is confirmed as a bug. label Oct 26, 2018
@@ -303,8 +324,7 @@ func showRegionsFromStartKeyCommandFunc(cmd *cobra.Command, args []string) {
fmt.Println("Error: unknown format")
return
}
// TODO: Deal with path escaped
prefix := regionKeyPrefix + "/" + key
prefix := regionKeyPrefix + "/" + url.QueryEscape(key)
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to update server-side to adapt this change?

Copy link
Member Author

Choose a reason for hiding this comment

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

It seems #1299 will deal with this problem. I will remove it from this PR.

@rleungx
Copy link
Member Author

rleungx commented Oct 26, 2018

/rebuild

Copy link
Contributor

@nolouch nolouch left a comment

Choose a reason for hiding this comment

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

LGTM

@nolouch nolouch merged commit a53e353 into tikv:master Oct 26, 2018
@disksing disksing added the needs-cherry-pick-release-2.1 The PR needs to cherry pick to release-2.1 branch. label Nov 7, 2018
disksing pushed a commit to oh-my-tidb/pd that referenced this pull request Nov 8, 2018
disksing added a commit that referenced this pull request Nov 8, 2018
* pdctl: fix region key problems in detach mode (#1298)

* pd-ctl: escape the key before query the corresponding region (#1299)

* pdctl: fix decode key (#1308)

Signed-off-by: disksing <i@disksing.com>
@nolouch nolouch added the needs-cherry-pick-release-2.0 The PR needs to cherry pick to release-2.0 branch. label Nov 13, 2018
disksing added a commit to oh-my-tidb/pd that referenced this pull request Nov 14, 2018
disksing added a commit that referenced this pull request Nov 14, 2018
* server, client: fix hanging problem when etcd failed to start (#1267)

* server: use same initialcluster config to restart joined member (#1279)

* fix server build

* pdctl: cherry pick bugfixes (#1298, #1299, #1308)

* server/api: fix the issue about `regions/check` API (#1311)

* fix join build

* fix pdctl build

* fix region test

* fix warnings
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-cherry-pick-release-2.0 The PR needs to cherry pick to release-2.0 branch. needs-cherry-pick-release-2.1 The PR needs to cherry pick to release-2.1 branch. type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants