Documentation ¶
Index ¶
- Constants
- func CheckStreamTimeoutLoop(ch <-chan *Lease, done <-chan struct{})
- func SetContext(req *Request, region *metapb.Region, peer *metapb.Peer) error
- type BatchCopStreamResponse
- type CmdType
- type CopStreamResponse
- type EndpointType
- type Lease
- type MPPStreamResponse
- type Request
- func (req *Request) BatchCop() *coprocessor.BatchRequest
- func (req *Request) BatchGet() *kvrpcpb.BatchGetRequest
- func (req *Request) BatchRollback() *kvrpcpb.BatchRollbackRequest
- func (req *Request) CancelMPPTask() *mpp.CancelTaskRequest
- func (req *Request) CheckLockObserver() *kvrpcpb.CheckLockObserverRequest
- func (req *Request) CheckSecondaryLocks() *kvrpcpb.CheckSecondaryLocksRequest
- func (req *Request) CheckTxnStatus() *kvrpcpb.CheckTxnStatusRequest
- func (req *Request) Cleanup() *kvrpcpb.CleanupRequest
- func (req *Request) Commit() *kvrpcpb.CommitRequest
- func (req *Request) Compact() *kvrpcpb.CompactRequest
- func (req *Request) Cop() *coprocessor.Request
- func (req *Request) DebugGetRegionProperties() *debugpb.GetRegionPropertiesRequest
- func (req *Request) DeleteRange() *kvrpcpb.DeleteRangeRequest
- func (req *Request) DispatchMPPTask() *mpp.DispatchTaskRequest
- func (req *Request) Empty() *tikvpb.BatchCommandsEmptyRequest
- func (req *Request) EnableStaleRead()
- func (req *Request) EstablishMPPConn() *mpp.EstablishMPPConnectionRequest
- func (req *Request) FlashbackToVersion() *kvrpcpb.FlashbackToVersionRequest
- func (req *Request) GC() *kvrpcpb.GCRequest
- func (req *Request) Get() *kvrpcpb.GetRequest
- func (req *Request) GetReplicaReadSeed() *uint32
- func (req *Request) IsDebugReq() bool
- func (req *Request) IsGlobalStaleRead() bool
- func (req *Request) IsGreenGCRequest() bool
- func (req *Request) IsMPPAlive() *mpp.IsAliveRequest
- func (req *Request) IsTxnWriteRequest() bool
- func (req *Request) LockWaitInfo() *kvrpcpb.GetLockWaitInfoRequest
- func (req *Request) MvccGetByKey() *kvrpcpb.MvccGetByKeyRequest
- func (req *Request) MvccGetByStartTs() *kvrpcpb.MvccGetByStartTsRequest
- func (req *Request) PessimisticLock() *kvrpcpb.PessimisticLockRequest
- func (req *Request) PessimisticRollback() *kvrpcpb.PessimisticRollbackRequest
- func (req *Request) PhysicalScanLock() *kvrpcpb.PhysicalScanLockRequest
- func (req *Request) PrepareFlashbackToVersion() *kvrpcpb.PrepareFlashbackToVersionRequest
- func (req *Request) Prewrite() *kvrpcpb.PrewriteRequest
- func (req *Request) RawBatchDelete() *kvrpcpb.RawBatchDeleteRequest
- func (req *Request) RawBatchGet() *kvrpcpb.RawBatchGetRequest
- func (req *Request) RawBatchPut() *kvrpcpb.RawBatchPutRequest
- func (req *Request) RawChecksum() *kvrpcpb.RawChecksumRequest
- func (req *Request) RawCompareAndSwap() *kvrpcpb.RawCASRequest
- func (req *Request) RawDelete() *kvrpcpb.RawDeleteRequest
- func (req *Request) RawDeleteRange() *kvrpcpb.RawDeleteRangeRequest
- func (req *Request) RawGet() *kvrpcpb.RawGetRequest
- func (req *Request) RawGetKeyTTL() *kvrpcpb.RawGetKeyTTLRequest
- func (req *Request) RawPut() *kvrpcpb.RawPutRequest
- func (req *Request) RawScan() *kvrpcpb.RawScanRequest
- func (req *Request) RegisterLockObserver() *kvrpcpb.RegisterLockObserverRequest
- func (req *Request) RemoveLockObserver() *kvrpcpb.RemoveLockObserverRequest
- func (req *Request) ResolveLock() *kvrpcpb.ResolveLockRequest
- func (req *Request) Scan() *kvrpcpb.ScanRequest
- func (req *Request) ScanLock() *kvrpcpb.ScanLockRequest
- func (req *Request) SplitRegion() *kvrpcpb.SplitRegionRequest
- func (req *Request) StoreSafeTS() *kvrpcpb.StoreSafeTSRequest
- func (req *Request) ToBatchCommandsRequest() *tikvpb.BatchCommandsRequest_Request
- func (req *Request) TxnHeartBeat() *kvrpcpb.TxnHeartBeatRequest
- func (req *Request) UnsafeDestroyRange() *kvrpcpb.UnsafeDestroyRangeRequest
- type ResourceGroupTagger
- type Response
- func CallDebugRPC(ctx context.Context, client debugpb.DebugClient, req *Request) (*Response, error)
- func CallRPC(ctx context.Context, client tikvpb.TikvClient, req *Request) (*Response, error)
- func FromBatchCommandsResponse(res *tikvpb.BatchCommandsResponse_Response) (*Response, error)
- func GenRegionErrorResp(req *Request, e *errorpb.Error) (*Response, error)
Constants ¶
const ( EngineLabelKey = "engine" EngineLabelTiFlash = "tiflash" EngineLabelTiFlashCompute = "tiflash_compute" )
Constants to determine engine type. They should be synced with PD.
Variables ¶
This section is empty.
Functions ¶
func CheckStreamTimeoutLoop ¶
func CheckStreamTimeoutLoop(ch <-chan *Lease, done <-chan struct{})
CheckStreamTimeoutLoop runs periodically to check is there any stream request timed out. Lease is an object to track stream requests, call this function with "go CheckStreamTimeoutLoop()" It is not guaranteed to call every Lease.Cancel() putting into channel when exits. If grpc-go supports SetDeadline(https://github.com/grpc/grpc-go/issues/2917), we can stop using this method.
Types ¶
type BatchCopStreamResponse ¶
type BatchCopStreamResponse struct { tikvpb.Tikv_BatchCoprocessorClient *coprocessor.BatchResponse Timeout time.Duration Lease // Shared by this object and a background goroutine. }
BatchCopStreamResponse comprises the BatchCoprocessorClient , the first result and timeout detector.
func (*BatchCopStreamResponse) Close ¶
func (resp *BatchCopStreamResponse) Close()
Close closes the BatchCopStreamResponse object.
func (*BatchCopStreamResponse) Recv ¶
func (resp *BatchCopStreamResponse) Recv() (*coprocessor.BatchResponse, error)
Recv overrides the stream client Recv() function.
type CmdType ¶
type CmdType uint16
CmdType represents the concrete request type in Request or response type in Response.
const ( CmdGet CmdType = 1 + iota CmdScan CmdPrewrite CmdCommit CmdCleanup CmdBatchGet CmdBatchRollback CmdScanLock CmdResolveLock CmdGC CmdDeleteRange CmdPessimisticLock CmdPessimisticRollback CmdTxnHeartBeat CmdCheckTxnStatus CmdCheckSecondaryLocks CmdFlashbackToVersion CmdPrepareFlashbackToVersion CmdRawGet CmdType = 256 + iota CmdRawBatchGet CmdRawPut CmdRawBatchPut CmdRawDelete CmdRawBatchDelete CmdRawDeleteRange CmdRawScan CmdGetKeyTTL CmdRawCompareAndSwap CmdRawChecksum CmdUnsafeDestroyRange CmdRegisterLockObserver CmdCheckLockObserver CmdRemoveLockObserver CmdPhysicalScanLock CmdStoreSafeTS CmdLockWaitInfo CmdCop CmdType = 512 + iota CmdCopStream CmdBatchCop CmdMPPTask // TODO: These non TiKV RPCs should be moved out of TiKV client CmdMPPConn // TODO: These non TiKV RPCs should be moved out of TiKV client CmdMPPCancel // TODO: These non TiKV RPCs should be moved out of TiKV client CmdMPPAlive // TODO: These non TiKV RPCs should be moved out of TiKV client CmdMvccGetByKey CmdType = 1024 + iota CmdMvccGetByStartTs CmdSplitRegion CmdDebugGetRegionProperties CmdType = 2048 + iota CmdCompact // TODO: These non TiKV RPCs should be moved out of TiKV client CmdEmpty CmdType = 3072 + iota )
CmdType values.
type CopStreamResponse ¶
type CopStreamResponse struct { tikvpb.Tikv_CoprocessorStreamClient *coprocessor.Response // The first result of Recv() Timeout time.Duration Lease // Shared by this object and a background goroutine. }
CopStreamResponse combines tikvpb.Tikv_CoprocessorStreamClient and the first Recv() result together. In streaming API, get grpc stream client may not involve any network packet, then region error have to be handled in Recv() function. This struct facilitates the error handling.
func (*CopStreamResponse) Close ¶
func (resp *CopStreamResponse) Close()
Close closes the CopStreamResponse object.
func (*CopStreamResponse) Recv ¶
func (resp *CopStreamResponse) Recv() (*coprocessor.Response, error)
Recv overrides the stream client Recv() function.
type EndpointType ¶
type EndpointType uint8
EndpointType represents the type of a remote endpoint..
const ( TiKV EndpointType = iota TiFlash TiDB TiFlashCompute )
EndpointType type enums.
func GetStoreTypeByMeta ¶
func GetStoreTypeByMeta(store *metapb.Store) EndpointType
GetStoreTypeByMeta gets store type by store meta pb.
func (EndpointType) IsTiFlashRelatedType ¶
func (t EndpointType) IsTiFlashRelatedType() bool
IsTiFlashRelatedType return true if it's tiflash or tiflash_compute.
func (EndpointType) Name ¶
func (t EndpointType) Name() string
Name returns the name of endpoint type.
type Lease ¶
type Lease struct { Cancel context.CancelFunc // contains filtered or unexported fields }
Lease is used to implement grpc stream timeout.
type MPPStreamResponse ¶
type MPPStreamResponse struct { tikvpb.Tikv_EstablishMPPConnectionClient *mpp.MPPDataPacket Timeout time.Duration Lease }
MPPStreamResponse is indeed a wrapped client that can receive data packet from tiflash mpp server.
func (*MPPStreamResponse) Close ¶
func (resp *MPPStreamResponse) Close()
Close closes the MPPStreamResponse object.
func (*MPPStreamResponse) Recv ¶
func (resp *MPPStreamResponse) Recv() (*mpp.MPPDataPacket, error)
Recv overrides the stream client Recv() function.
type Request ¶
type Request struct { Type CmdType Req interface{} kvrpcpb.Context ReadReplicaScope string // remove txnScope after tidb removed txnScope TxnScope string ReplicaReadType kv.ReplicaReadType // different from `kvrpcpb.Context.ReplicaRead` ReplicaReadSeed *uint32 // pointer to follower read seed in snapshot/coprocessor StoreTp EndpointType // ForwardedHost is the address of a store which will handle the request. It's different from // the address the request sent to. // If it's not empty, the store which receive the request will forward it to // the forwarded host. It's useful when network partition occurs. ForwardedHost string }
Request wraps all kv/coprocessor requests.
func NewReplicaReadRequest ¶
func NewReplicaReadRequest(typ CmdType, pointer interface{}, replicaReadType kv.ReplicaReadType, replicaReadSeed *uint32, ctxs ...kvrpcpb.Context) *Request
NewReplicaReadRequest returns new kv rpc request with replica read.
func NewRequest ¶
NewRequest returns new kv rpc request.
func (*Request) BatchCop ¶
func (req *Request) BatchCop() *coprocessor.BatchRequest
BatchCop returns BatchCop request in request.
func (*Request) BatchGet ¶
func (req *Request) BatchGet() *kvrpcpb.BatchGetRequest
BatchGet returns BatchGetRequest in request.
func (*Request) BatchRollback ¶
func (req *Request) BatchRollback() *kvrpcpb.BatchRollbackRequest
BatchRollback returns BatchRollbackRequest in request.
func (*Request) CancelMPPTask ¶
func (req *Request) CancelMPPTask() *mpp.CancelTaskRequest
CancelMPPTask returns canceling task in request
func (*Request) CheckLockObserver ¶
func (req *Request) CheckLockObserver() *kvrpcpb.CheckLockObserverRequest
CheckLockObserver returns CheckLockObserverRequest in request.
func (*Request) CheckSecondaryLocks ¶
func (req *Request) CheckSecondaryLocks() *kvrpcpb.CheckSecondaryLocksRequest
CheckSecondaryLocks returns CheckSecondaryLocksRequest in request.
func (*Request) CheckTxnStatus ¶
func (req *Request) CheckTxnStatus() *kvrpcpb.CheckTxnStatusRequest
CheckTxnStatus returns CheckTxnStatusRequest in request.
func (*Request) Cleanup ¶
func (req *Request) Cleanup() *kvrpcpb.CleanupRequest
Cleanup returns CleanupRequest in request.
func (*Request) Commit ¶
func (req *Request) Commit() *kvrpcpb.CommitRequest
Commit returns CommitRequest in request.
func (*Request) Compact ¶
func (req *Request) Compact() *kvrpcpb.CompactRequest
Compact returns CompactRequest in request.
func (*Request) Cop ¶
func (req *Request) Cop() *coprocessor.Request
Cop returns coprocessor request in request.
func (*Request) DebugGetRegionProperties ¶
func (req *Request) DebugGetRegionProperties() *debugpb.GetRegionPropertiesRequest
DebugGetRegionProperties returns GetRegionPropertiesRequest in request.
func (*Request) DeleteRange ¶
func (req *Request) DeleteRange() *kvrpcpb.DeleteRangeRequest
DeleteRange returns DeleteRangeRequest in request.
func (*Request) DispatchMPPTask ¶
func (req *Request) DispatchMPPTask() *mpp.DispatchTaskRequest
DispatchMPPTask returns dispatch task request in request.
func (*Request) Empty ¶
func (req *Request) Empty() *tikvpb.BatchCommandsEmptyRequest
Empty returns BatchCommandsEmptyRequest in request.
func (*Request) EnableStaleRead ¶
func (req *Request) EnableStaleRead()
EnableStaleRead enables stale read
func (*Request) EstablishMPPConn ¶
func (req *Request) EstablishMPPConn() *mpp.EstablishMPPConnectionRequest
EstablishMPPConn returns EstablishMPPConnectionRequest in request.
func (*Request) FlashbackToVersion ¶
func (req *Request) FlashbackToVersion() *kvrpcpb.FlashbackToVersionRequest
FlashbackToVersion returns FlashbackToVersionRequest in request.
func (*Request) Get ¶
func (req *Request) Get() *kvrpcpb.GetRequest
Get returns GetRequest in request.
func (*Request) GetReplicaReadSeed ¶
GetReplicaReadSeed returns ReplicaReadSeed pointer.
func (*Request) IsDebugReq ¶
IsDebugReq check whether the req is debug req.
func (*Request) IsGlobalStaleRead ¶
IsGlobalStaleRead checks if the request is a global stale read request.
func (*Request) IsGreenGCRequest ¶
IsGreenGCRequest checks if the request is used by Green GC's protocol. This is used for failpoints to inject errors to specified RPC requests.
func (*Request) IsMPPAlive ¶
func (req *Request) IsMPPAlive() *mpp.IsAliveRequest
IsMPPAlive returns IsAlive request in request.
func (*Request) IsTxnWriteRequest ¶
IsTxnWriteRequest checks if the request is a transactional write request. This is used for failpoints to inject errors to specified RPC requests.
func (*Request) LockWaitInfo ¶
func (req *Request) LockWaitInfo() *kvrpcpb.GetLockWaitInfoRequest
LockWaitInfo returns GetLockWaitInfoRequest in request.
func (*Request) MvccGetByKey ¶
func (req *Request) MvccGetByKey() *kvrpcpb.MvccGetByKeyRequest
MvccGetByKey returns MvccGetByKeyRequest in request.
func (*Request) MvccGetByStartTs ¶
func (req *Request) MvccGetByStartTs() *kvrpcpb.MvccGetByStartTsRequest
MvccGetByStartTs returns MvccGetByStartTsRequest in request.
func (*Request) PessimisticLock ¶
func (req *Request) PessimisticLock() *kvrpcpb.PessimisticLockRequest
PessimisticLock returns PessimisticLockRequest in request.
func (*Request) PessimisticRollback ¶
func (req *Request) PessimisticRollback() *kvrpcpb.PessimisticRollbackRequest
PessimisticRollback returns PessimisticRollbackRequest in request.
func (*Request) PhysicalScanLock ¶
func (req *Request) PhysicalScanLock() *kvrpcpb.PhysicalScanLockRequest
PhysicalScanLock returns PhysicalScanLockRequest in request.
func (*Request) PrepareFlashbackToVersion ¶
func (req *Request) PrepareFlashbackToVersion() *kvrpcpb.PrepareFlashbackToVersionRequest
PrepareFlashbackToVersion returns PrepareFlashbackToVersion in request.
func (*Request) Prewrite ¶
func (req *Request) Prewrite() *kvrpcpb.PrewriteRequest
Prewrite returns PrewriteRequest in request.
func (*Request) RawBatchDelete ¶
func (req *Request) RawBatchDelete() *kvrpcpb.RawBatchDeleteRequest
RawBatchDelete returns RawBatchDeleteRequest in request.
func (*Request) RawBatchGet ¶
func (req *Request) RawBatchGet() *kvrpcpb.RawBatchGetRequest
RawBatchGet returns RawBatchGetRequest in request.
func (*Request) RawBatchPut ¶
func (req *Request) RawBatchPut() *kvrpcpb.RawBatchPutRequest
RawBatchPut returns RawBatchPutRequest in request.
func (*Request) RawChecksum ¶
func (req *Request) RawChecksum() *kvrpcpb.RawChecksumRequest
RawChecksum returns RawChecksumRequest in request.
func (*Request) RawCompareAndSwap ¶
func (req *Request) RawCompareAndSwap() *kvrpcpb.RawCASRequest
RawCompareAndSwap returns RawCASRequest in request.
func (*Request) RawDelete ¶
func (req *Request) RawDelete() *kvrpcpb.RawDeleteRequest
RawDelete returns PrewriteRequest in request.
func (*Request) RawDeleteRange ¶
func (req *Request) RawDeleteRange() *kvrpcpb.RawDeleteRangeRequest
RawDeleteRange returns RawDeleteRangeRequest in request.
func (*Request) RawGet ¶
func (req *Request) RawGet() *kvrpcpb.RawGetRequest
RawGet returns RawGetRequest in request.
func (*Request) RawGetKeyTTL ¶
func (req *Request) RawGetKeyTTL() *kvrpcpb.RawGetKeyTTLRequest
RawGetKeyTTL returns RawGetKeyTTLRequest in request.
func (*Request) RawPut ¶
func (req *Request) RawPut() *kvrpcpb.RawPutRequest
RawPut returns RawPutRequest in request.
func (*Request) RawScan ¶
func (req *Request) RawScan() *kvrpcpb.RawScanRequest
RawScan returns RawScanRequest in request.
func (*Request) RegisterLockObserver ¶
func (req *Request) RegisterLockObserver() *kvrpcpb.RegisterLockObserverRequest
RegisterLockObserver returns RegisterLockObserverRequest in request.
func (*Request) RemoveLockObserver ¶
func (req *Request) RemoveLockObserver() *kvrpcpb.RemoveLockObserverRequest
RemoveLockObserver returns RemoveLockObserverRequest in request.
func (*Request) ResolveLock ¶
func (req *Request) ResolveLock() *kvrpcpb.ResolveLockRequest
ResolveLock returns ResolveLockRequest in request.
func (*Request) Scan ¶
func (req *Request) Scan() *kvrpcpb.ScanRequest
Scan returns ScanRequest in request.
func (*Request) ScanLock ¶
func (req *Request) ScanLock() *kvrpcpb.ScanLockRequest
ScanLock returns ScanLockRequest in request.
func (*Request) SplitRegion ¶
func (req *Request) SplitRegion() *kvrpcpb.SplitRegionRequest
SplitRegion returns SplitRegionRequest in request.
func (*Request) StoreSafeTS ¶
func (req *Request) StoreSafeTS() *kvrpcpb.StoreSafeTSRequest
StoreSafeTS returns StoreSafeTSRequest in request.
func (*Request) ToBatchCommandsRequest ¶
func (req *Request) ToBatchCommandsRequest() *tikvpb.BatchCommandsRequest_Request
ToBatchCommandsRequest converts the request to an entry in BatchCommands request.
func (*Request) TxnHeartBeat ¶
func (req *Request) TxnHeartBeat() *kvrpcpb.TxnHeartBeatRequest
TxnHeartBeat returns TxnHeartBeatRequest in request.
func (*Request) UnsafeDestroyRange ¶
func (req *Request) UnsafeDestroyRange() *kvrpcpb.UnsafeDestroyRangeRequest
UnsafeDestroyRange returns UnsafeDestroyRangeRequest in request.
type ResourceGroupTagger ¶
type ResourceGroupTagger func(req *Request)
ResourceGroupTagger is used to fill the ResourceGroupTag in the kvrpcpb.Context.
type Response ¶
type Response struct {
Resp interface{}
}
Response wraps all kv/coprocessor responses.
func CallDebugRPC ¶
CallDebugRPC launches a debug rpc call.
func CallRPC ¶
CallRPC launches a rpc call. ch is needed to implement timeout for coprocessor streaming, the stream object's cancel function will be sent to the channel, together with a lease checked by a background goroutine.
func FromBatchCommandsResponse ¶
func FromBatchCommandsResponse(res *tikvpb.BatchCommandsResponse_Response) (*Response, error)
FromBatchCommandsResponse converts a BatchCommands response to Response.
func GenRegionErrorResp ¶
GenRegionErrorResp returns corresponding Response with specified RegionError according to the given req.
func (*Response) GetExecDetailsV2 ¶
func (resp *Response) GetExecDetailsV2() *kvrpcpb.ExecDetailsV2
GetExecDetailsV2 returns the ExecDetailsV2 of the underlying concrete response.