Skip to content

Commit

Permalink
keyspace: adjust keyspacePatrolBatchSize to avoid too many operatio…
Browse files Browse the repository at this point in the history
…ns in txn request (#6562)

close #6561

Signed-off-by: lhy1024 <admin@liudos.us>
  • Loading branch information
lhy1024 authored Jun 6, 2023
1 parent 0451b4e commit 2654eac
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 3 additions & 1 deletion pkg/keyspace/keyspace.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 6 additions & 2 deletions tests/pdctl/keyspace/keyspace_group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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++ {

This comment has been minimized.

Copy link
@rleungx

rleungx Jun 7, 2023

Member

And why do we need 500? I think a little larger than 128 is enough.

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()
Expand All @@ -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))

This comment has been minimized.

Copy link
@rleungx

rleungx Jun 7, 2023

Member

Will the test run too long?


re.NoError(failpoint.Disable("github.com/tikv/pd/pkg/keyspace/acceleratedAllocNodes"))
re.NoError(failpoint.Disable("github.com/tikv/pd/server/delayStartServerLoop"))
Expand Down

0 comments on commit 2654eac

Please sign in to comment.