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

pd-ctl: support StartKeyspaceID and EndKeyspaceID parameters #6688

Closed
binshi-bing opened this issue Jun 26, 2023 · 0 comments · Fixed by #6689
Closed

pd-ctl: support StartKeyspaceID and EndKeyspaceID parameters #6688

binshi-bing opened this issue Jun 26, 2023 · 0 comments · Fixed by #6689
Labels
type/enhancement The issue or PR belongs to an enhancement.

Comments

@binshi-bing
Copy link
Contributor

binshi-bing commented Jun 26, 2023

Enhancement Task

root@serverless-cluster-pd-0:/# ./pd-ctl keyspace-group split help
Usage:
pd-ctl keyspace-group split <keyspace_group_id> <new_keyspace_group_id> [<keyspace_id>] [flags]

// SplitKeyspaceGroupByIDParams defines the params for splitting a keyspace group.
type SplitKeyspaceGroupByIDParams struct {
	NewID     uint32   `json:"new-id"`
	Keyspaces []uint32 `json:"keyspaces"`
	// StartKeyspaceID and EndKeyspaceID are used to indicate the range of keyspaces to be split.
	StartKeyspaceID uint32 `json:"start-keyspace-id"`
	EndKeyspaceID   uint32 `json:"end-keyspace-id"`
}
func splitKeyspaceGroupCommandFunc(cmd *cobra.Command, args []string) {
	if len(args) < 3 {
		cmd.Usage()
		return
	}
	_, err := strconv.ParseUint(args[0], 10, 32)
	if err != nil {
		cmd.Printf("Failed to parse the old keyspace group ID: %s\n", err)
		return
	}
	newID, err := strconv.ParseUint(args[1], 10, 32)
	if err != nil {
		cmd.Printf("Failed to parse the new keyspace group ID: %s\n", err)
		return
	}
	keyspaces := make([]uint32, 0, len(args)-2)
	for _, arg := range args[2:] {
		id, err := strconv.ParseUint(arg, 10, 32)
		if err != nil {
			cmd.Printf("Failed to parse the keyspace ID: %s\n", err)
			return
		}
		keyspaces = append(keyspaces, uint32(id))
	}
	postJSON(cmd, fmt.Sprintf("%s/%s/split", keyspaceGroupsPrefix, args[0]), map[string]interface{}{
		"new-id":    uint32(newID),
		"keyspaces": keyspaces,
	})
@binshi-bing binshi-bing added the type/enhancement The issue or PR belongs to an enhancement. label Jun 26, 2023
ti-chi-bot bot pushed a commit that referenced this issue Jun 27, 2023
close #6687, close #6688

Add split-range cmd and fix duplicate keyspaces
    
    1. Add split-range cmd to support StartKeyspaceID and EndKeyspaceID parameters.
    2. Fix "split 0 2 2 2" generate duplicate keyspaces in the keyspace list of the group"

Signed-off-by: Bin Shi <[email protected]>
@binshi-bing binshi-bing changed the title pd-ctl doesn't support StartKeyspaceID and EndKeyspaceID parameters pd-ctl: support StartKeyspaceID and EndKeyspaceID parameters Jun 29, 2023
rleungx pushed a commit to rleungx/pd that referenced this issue Aug 2, 2023
close tikv#6687, close tikv#6688

Add split-range cmd and fix duplicate keyspaces
    
    1. Add split-range cmd to support StartKeyspaceID and EndKeyspaceID parameters.
    2. Fix "split 0 2 2 2" generate duplicate keyspaces in the keyspace list of the group"

Signed-off-by: Bin Shi <[email protected]>
rleungx pushed a commit to rleungx/pd that referenced this issue Aug 2, 2023
close tikv#6687, close tikv#6688

Add split-range cmd and fix duplicate keyspaces
    
    1. Add split-range cmd to support StartKeyspaceID and EndKeyspaceID parameters.
    2. Fix "split 0 2 2 2" generate duplicate keyspaces in the keyspace list of the group"

Signed-off-by: Bin Shi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/enhancement The issue or PR belongs to an enhancement.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant