Merge pull request #968 from bufferflies/add_log

Add log for detail rpc failed reason
This commit is contained in:
buffer 2023-09-12 20:41:33 +08:00 committed by GitHub
commit 78834eef77
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions

View File

@ -37,6 +37,7 @@ package client
import (
"context"
"fmt"
"math"
"runtime/trace"
"sync"
@ -793,7 +794,8 @@ func sendBatchRequest(
case <-timer.C:
return nil, errors.WithMessage(context.DeadlineExceeded, "wait sendLoop")
}
metrics.TiKVBatchWaitDuration.Observe(float64(time.Since(start)))
waitDuration := time.Since(start)
metrics.TiKVBatchWaitDuration.Observe(float64(waitDuration))
select {
case res, ok := <-entry.res:
@ -808,7 +810,8 @@ func sendBatchRequest(
return nil, errors.WithStack(ctx.Err())
case <-timer.C:
atomic.StoreInt32(&entry.canceled, 1)
return nil, errors.WithMessage(context.DeadlineExceeded, "wait recvLoop")
reason := fmt.Sprintf("wait recvLoop timeout,timeout:%s, wait_duration:%s:", timeout, waitDuration)
return nil, errors.WithMessage(context.DeadlineExceeded, reason)
}
}

View File

@ -113,7 +113,7 @@ type RegionRequestSender struct {
}
func (s *RegionRequestSender) String() string {
return fmt.Sprintf("{replicaSelector: %v}", s.replicaSelector.String())
return fmt.Sprintf("{rpcError:%v,replicaSelector: %v}", s.rpcError, s.replicaSelector.String())
}
// RegionRequestRuntimeStats records the runtime stats of send region requests.