Documentation ¶
Index ¶
- Constants
- Variables
- func BytesToString(numBytes int64) string
- func CompatibleParseGCTime(value string) (time.Time, error)
- func FormatBytes(numBytes int64) string
- func FormatDuration(d time.Duration) string
- func SetSessionID(ctx context.Context, sessionID uint64) context.Context
- func WithRecovery(exec func(), recoverFn func(r interface{}))
- type CommitDetails
- type ExecDetails
- type InterceptedPDClient
- func (m InterceptedPDClient) GetPrevRegion(ctx context.Context, key []byte) (*pd.Region, error)
- func (m InterceptedPDClient) GetRegion(ctx context.Context, key []byte) (*pd.Region, error)
- func (m InterceptedPDClient) GetRegionByID(ctx context.Context, regionID uint64) (*pd.Region, error)
- func (m InterceptedPDClient) GetStore(ctx context.Context, storeID uint64) (*metapb.Store, error)
- func (m InterceptedPDClient) GetTS(ctx context.Context) (int64, int64, error)
- func (m InterceptedPDClient) GetTSAsync(ctx context.Context) pd.TSFuture
- func (m InterceptedPDClient) ScanRegions(ctx context.Context, key, endKey []byte, limit int) ([]*pd.Region, error)
- type LockKeysDetails
- type RateLimit
- type ScanDetail
- type TSSet
- type TimeDetail
Constants ¶
const GCTimeFormat = "20060102-15:04:05 -0700"
GCTimeFormat is the format that gc_worker used to store times.
Variables ¶
var ( // CommitDetailCtxKey presents CommitDetail info key in context. CommitDetailCtxKey = commitDetailCtxKeyType{} // LockKeysDetailCtxKey presents LockKeysDetail info key in context. LockKeysDetailCtxKey = lockKeysDetailCtxKeyType{} // ExecDetailsKey presents ExecDetail info key in context. ExecDetailsKey = execDetailsCtxKeyType{} )
var ( // MockRetryableErrorResp mocks an retryable error while processing response MockRetryableErrorResp failpoint.Failpoint // MockScatterRegionTimeout mocks timeout when trying to scatter region MockScatterRegionTimeout failpoint.Failpoint // MockSplitRegionTimeout mocks timeout when trying to split region MockSplitRegionTimeout failpoint.Failpoint )
var SessionID = sessionIDCtxKey{}
SessionID is the context key type to mark a session.
Functions ¶
func BytesToString ¶
BytesToString converts the memory consumption to a readable string.
func CompatibleParseGCTime ¶
CompatibleParseGCTime parses a string with `GCTimeFormat` and returns a time.Time. If `value` can't be parsed as that format, truncate to last space and try again. This function is only useful when loading times that saved by gc_worker. We have changed the format that gc_worker saves time (removed the last field), but when loading times it should be compatible with the old format.
func FormatBytes ¶
FormatBytes uses to format bytes, this function will prune precision before format bytes.
func FormatDuration ¶
FormatDuration uses to format duration, this function will prune precision before format duration. Pruning precision is for human readability. The prune rule is:
- if the duration was less than 1us, return the original string.
- readable value >=10, keep 1 decimal, otherwise, keep 2 decimal. such as: 9.412345ms -> 9.41ms 10.412345ms -> 10.4ms 5.999s -> 6s 100.45µs -> 100.5µs
func SetSessionID ¶
SetSessionID sets session id into context
func WithRecovery ¶
func WithRecovery(exec func(), recoverFn func(r interface{}))
WithRecovery wraps goroutine startup call with force recovery. it will dump current goroutine stack into log if catch any recover result.
exec: execute logic function. recoverFn: handler will be called after recover and before dump stack, passing `nil` means noop.
Types ¶
type CommitDetails ¶
type CommitDetails struct { GetCommitTsTime time.Duration PrewriteTime time.Duration WaitPrewriteBinlogTime time.Duration CommitTime time.Duration LocalLatchTime time.Duration CommitBackoffTime int64 Mu struct { sync.Mutex BackoffTypes []string } ResolveLockTime int64 WriteKeys int WriteSize int PrewriteRegionNum int32 TxnRetry int }
CommitDetails contains commit detail information.
func (*CommitDetails) Clone ¶
func (cd *CommitDetails) Clone() *CommitDetails
Clone returns a deep copy of itself.
func (*CommitDetails) Merge ¶
func (cd *CommitDetails) Merge(other *CommitDetails)
Merge merges commit details into itself.
type ExecDetails ¶
type ExecDetails struct { BackoffCount int64 BackoffDuration int64 WaitKVRespDuration int64 WaitPDRespDuration int64 }
ExecDetails contains execution detail info.
type InterceptedPDClient ¶
InterceptedPDClient is a PD's wrapper client to record stmt detail.
func (InterceptedPDClient) GetPrevRegion ¶
GetPrevRegion implements pd.Client#GetPrevRegion.
func (InterceptedPDClient) GetRegionByID ¶
func (m InterceptedPDClient) GetRegionByID(ctx context.Context, regionID uint64) (*pd.Region, error)
GetRegionByID implements pd.Client#GetRegionByID.
func (InterceptedPDClient) GetTSAsync ¶
func (m InterceptedPDClient) GetTSAsync(ctx context.Context) pd.TSFuture
GetTSAsync implements pd.Client#GetTSAsync.
func (InterceptedPDClient) ScanRegions ¶
func (m InterceptedPDClient) ScanRegions(ctx context.Context, key, endKey []byte, limit int) ([]*pd.Region, error)
ScanRegions implements pd.Client#ScanRegions.
type LockKeysDetails ¶
type LockKeysDetails struct { TotalTime time.Duration RegionNum int32 LockKeys int32 ResolveLockTime int64 BackoffTime int64 Mu struct { sync.Mutex BackoffTypes []string } LockRPCTime int64 LockRPCCount int64 RetryCount int }
LockKeysDetails contains pessimistic lock keys detail information.
func (*LockKeysDetails) Clone ¶
func (ld *LockKeysDetails) Clone() *LockKeysDetails
Clone returns a deep copy of itself.
func (*LockKeysDetails) Merge ¶
func (ld *LockKeysDetails) Merge(lockKey *LockKeysDetails)
Merge merges lock keys execution details into self.
type RateLimit ¶
type RateLimit struct {
// contains filtered or unexported fields
}
RateLimit wraps a fix sized channel to control concurrency.
func NewRateLimit ¶
NewRateLimit creates a limit controller with capacity n.
func (*RateLimit) GetCapacity ¶
GetCapacity returns the token capacity.
type ScanDetail ¶
type ScanDetail struct { // TotalKeys is the approximate number of MVCC keys meet during scanning. It includes // deleted versions, but does not include RocksDB tombstone keys. TotalKeys int64 // ProcessedKeys is the number of user keys scanned from the storage. // It does not include deleted version or RocksDB tombstone keys. // For Coprocessor requests, it includes keys that has been filtered out by Selection. ProcessedKeys int64 // RocksdbDeleteSkippedCount is the total number of deletes and single deletes skipped over during // iteration, i.e. how many RocksDB tombstones are skipped. RocksdbDeleteSkippedCount uint64 // RocksdbKeySkippedCount it the total number of internal keys skipped over during iteration. RocksdbKeySkippedCount uint64 // RocksdbBlockCacheHitCount is the total number of RocksDB block cache hits. RocksdbBlockCacheHitCount uint64 // RocksdbBlockReadCount is the total number of block reads (with IO). RocksdbBlockReadCount uint64 // RocksdbBlockReadByte is the total number of bytes from block reads. RocksdbBlockReadByte uint64 }
ScanDetail contains coprocessor scan detail information.
func (*ScanDetail) Merge ¶
func (sd *ScanDetail) Merge(scanDetail *ScanDetail)
Merge merges scan detail execution details into self.
func (*ScanDetail) MergeFromScanDetailV2 ¶
func (sd *ScanDetail) MergeFromScanDetailV2(scanDetail *kvrpcpb.ScanDetailV2)
MergeFromScanDetailV2 merges scan detail from pb into itself.
func (*ScanDetail) String ¶
func (sd *ScanDetail) String() string
String implements the fmt.Stringer interface.
type TimeDetail ¶
type TimeDetail struct { // WaitWallTimeMs is the off-cpu wall time which is elapsed in TiKV side. Usually this includes queue waiting time and // other kind of waitings in series. ProcessTime time.Duration // Off-cpu and on-cpu wall time elapsed to actually process the request payload. It does not // include `wait_wall_time`. // This field is very close to the CPU time in most cases. Some wait time spend in RocksDB // cannot be excluded for now, like Mutex wait time, which is included in this field, so that // this field is called wall time instead of CPU time. WaitTime time.Duration }
TimeDetail contains coprocessor time detail information.
func (*TimeDetail) MergeFromTimeDetail ¶
func (td *TimeDetail) MergeFromTimeDetail(timeDetail *kvrpcpb.TimeDetail)
MergeFromTimeDetail merges time detail from pb into itself.
func (*TimeDetail) String ¶
func (td *TimeDetail) String() string
String implements the fmt.Stringer interface.