Skip to content

Commit

Permalink
Merge remote-tracking branch 'nolouch/add-lock-metrics' into add-lock…
Browse files Browse the repository at this point in the history
…-metrics
  • Loading branch information
nolouch committed Mar 11, 2024
2 parents 37f3a98 + 846ddec commit 1bf72a3
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
22 changes: 19 additions & 3 deletions client/keyspace_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"github.com/opentracing/opentracing-go"
"github.com/pingcap/errors"
"github.com/pingcap/kvproto/pkg/keyspacepb"
"github.com/tikv/pd/client/errs"
)

// KeyspaceClient manages keyspace metadata.
Expand Down Expand Up @@ -56,7 +57,12 @@ func (c *client) LoadKeyspace(ctx context.Context, name string) (*keyspacepb.Key
Header: c.requestHeader(),
Name: name,
}
resp, err := c.keyspaceClient().LoadKeyspace(ctx, req)
protoClient := c.keyspaceClient()
if protoClient == nil {
cancel()
return nil, errs.ErrClientGetProtoClient
}
resp, err := protoClient.LoadKeyspace(ctx, req)
cancel()

if err != nil {
Expand Down Expand Up @@ -96,7 +102,12 @@ func (c *client) UpdateKeyspaceState(ctx context.Context, id uint32, state keysp
Id: id,
State: state,
}
resp, err := c.keyspaceClient().UpdateKeyspaceState(ctx, req)
protoClient := c.keyspaceClient()
if protoClient == nil {
cancel()
return nil, errs.ErrClientGetProtoClient
}
resp, err := protoClient.UpdateKeyspaceState(ctx, req)
cancel()

if err != nil {
Expand Down Expand Up @@ -135,7 +146,12 @@ func (c *client) GetAllKeyspaces(ctx context.Context, startID uint32, limit uint
StartId: startID,
Limit: limit,
}
resp, err := c.keyspaceClient().GetAllKeyspaces(ctx, req)
protoClient := c.keyspaceClient()
if protoClient == nil {
cancel()
return nil, errs.ErrClientGetProtoClient
}
resp, err := protoClient.GetAllKeyspaces(ctx, req)
cancel()

if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions tools/pd-api-bench/cases/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ func (c *httpController) run() {
qps := c.GetQPS()
burst := c.GetBurst()
cliNum := int64(len(c.clients))
tt := time.Duration(base/qps*burst*cliNum) * time.Microsecond
tt := time.Duration(base*burst*cliNum/qps) * time.Microsecond
log.Info("begin to run http case", zap.String("case", c.Name()), zap.Int64("qps", qps), zap.Int64("burst", burst), zap.Duration("interval", tt))
for _, hCli := range c.clients {
c.wg.Add(1)
Expand Down Expand Up @@ -283,7 +283,7 @@ func (c *gRPCController) run() {
qps := c.GetQPS()
burst := c.GetBurst()
cliNum := int64(len(c.clients))
tt := time.Duration(base/qps*burst*cliNum) * time.Microsecond
tt := time.Duration(base*burst*cliNum/qps) * time.Microsecond
log.Info("begin to run gRPC case", zap.String("case", c.Name()), zap.Int64("qps", qps), zap.Int64("burst", burst), zap.Duration("interval", tt))
for _, cli := range c.clients {
c.wg.Add(1)
Expand Down Expand Up @@ -352,7 +352,7 @@ func (c *etcdController) run() {
qps := c.GetQPS()
burst := c.GetBurst()
cliNum := int64(len(c.clients))
tt := time.Duration(base/qps*burst*cliNum) * time.Microsecond
tt := time.Duration(base*burst*cliNum/qps) * time.Microsecond
log.Info("begin to run etcd case", zap.String("case", c.Name()), zap.Int64("qps", qps), zap.Int64("burst", burst), zap.Duration("interval", tt))
err := c.Init(c.ctx, c.clients[0])
if err != nil {
Expand Down

0 comments on commit 1bf72a3

Please sign in to comment.