diff --git a/pkg/keyspace/keyspace.go b/pkg/keyspace/keyspace.go index 4827587b7aa..deb6e4fc625 100644 --- a/pkg/keyspace/keyspace.go +++ b/pkg/keyspace/keyspace.go @@ -50,7 +50,9 @@ const ( // TSOKeyspaceGroupIDKey is the key for tso keyspace group id in keyspace config. TSOKeyspaceGroupIDKey = "tso_keyspace_group_id" // keyspacePatrolBatchSize is the batch size for keyspace assignment patrol. - keyspacePatrolBatchSize = 256 + // the limit of etcd txn op is 128, keyspacePatrolBatchSize need to be less than it. + // See: https://github.com/etcd-io/etcd/blob/d3e43d4de6f6d9575b489dd7850a85e37e0f6b6c/server/embed/config.go#L61 + keyspacePatrolBatchSize = 120 ) // Config is the interface for keyspace config. diff --git a/tests/pdctl/keyspace/keyspace_group_test.go b/tests/pdctl/keyspace/keyspace_group_test.go index 3429eb56072..28cf968e04c 100644 --- a/tests/pdctl/keyspace/keyspace_group_test.go +++ b/tests/pdctl/keyspace/keyspace_group_test.go @@ -95,8 +95,12 @@ func TestSplitKeyspaceGroup(t *testing.T) { defer cancel() re.NoError(failpoint.Enable("github.com/tikv/pd/pkg/keyspace/acceleratedAllocNodes", `return(true)`)) re.NoError(failpoint.Enable("github.com/tikv/pd/server/delayStartServerLoop", `return(true)`)) + keyspaces := make([]string, 0) + for i := 0; i < 500; i++ { + keyspaces = append(keyspaces, fmt.Sprintf("keyspace_%d", i)) + } tc, err := tests.NewTestAPICluster(ctx, 3, func(conf *config.Config, serverName string) { - conf.Keyspace.PreAlloc = []string{"keyspace_a", "keyspace_b"} + conf.Keyspace.PreAlloc = keyspaces }) re.NoError(err) err = tc.RunInitialServers() @@ -122,7 +126,7 @@ func TestSplitKeyspaceGroup(t *testing.T) { output, err := pdctl.ExecuteCommand(cmd, args...) re.NoError(err) return strings.Contains(string(output), "Success") - }) + }, testutil.WithWaitFor(20*time.Second)) re.NoError(failpoint.Disable("github.com/tikv/pd/pkg/keyspace/acceleratedAllocNodes")) re.NoError(failpoint.Disable("github.com/tikv/pd/server/delayStartServerLoop"))