Documentation ¶
Index ¶
- type ClientHelper
- type ConfigProbe
- type IsoLevel
- type KVSnapshot
- func (s *KVSnapshot) BatchGet(ctx context.Context, keys [][]byte) (map[string][]byte, error)
- func (s *KVSnapshot) Get(ctx context.Context, k []byte) ([]byte, error)
- func (s *KVSnapshot) Iter(k []byte, upperBound []byte) (unionstore.Iterator, error)
- func (s *KVSnapshot) IterReverse(k []byte) (unionstore.Iterator, error)
- func (s *KVSnapshot) SetIsStatenessReadOnly(b bool)
- func (s *KVSnapshot) SetIsolationLevel(level IsoLevel)
- func (s *KVSnapshot) SetKeyOnly(b bool)
- func (s *KVSnapshot) SetMatchStoreLabels(labels []*metapb.StoreLabel)
- func (s *KVSnapshot) SetNotFillCache(b bool)
- func (s *KVSnapshot) SetPriority(pri txnutil.Priority)
- func (s *KVSnapshot) SetReadReplicaScope(scope string)
- func (s *KVSnapshot) SetReplicaRead(readType kv.ReplicaReadType)
- func (s *KVSnapshot) SetResourceGroupTag(tag []byte)
- func (s *KVSnapshot) SetRuntimeStats(stats *SnapshotRuntimeStats)
- func (s *KVSnapshot) SetSampleStep(step uint32)
- func (s *KVSnapshot) SetScanBatchSize(batchSize int)
- func (s *KVSnapshot) SetSnapshotTS(ts uint64)
- func (s *KVSnapshot) SetTaskID(id uint64)
- func (s *KVSnapshot) SetTxnScope(scope string)
- func (s *KVSnapshot) SetVars(vars *kv.Variables)
- func (s *KVSnapshot) SnapCacheHitCount() int
- func (s *KVSnapshot) SnapCacheSize() int
- type Scanner
- type SnapshotProbe
- func (s SnapshotProbe) BatchGetSingleRegion(bo *retry.Backoffer, region locate.RegionVerID, keys [][]byte, ...) error
- func (s SnapshotProbe) FormatStats() string
- func (s SnapshotProbe) MergeExecDetail(detail *kvrpcpb.ExecDetailsV2)
- func (s SnapshotProbe) MergeRegionRequestStats(stats map[tikvrpc.CmdType]*locate.RPCRuntimeStats)
- func (s SnapshotProbe) NewScanner(start, end []byte, batchSize int, reverse bool) (*Scanner, error)
- func (s SnapshotProbe) RecordBackoffInfo(bo *retry.Backoffer)
- type SnapshotRuntimeStats
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ClientHelper ¶
type ClientHelper struct { locate.RegionRequestRuntimeStats // contains filtered or unexported fields }
ClientHelper wraps LockResolver and RegionRequestSender. It's introduced to support the new lock resolving pattern in the large transaction. In the large transaction protocol, sending requests and resolving locks are context-dependent. For example, when a send request meets a secondary lock, we'll call ResolveLock, and if the lock belongs to a large transaction, we may retry the request. If there is no context information about the resolved locks, we'll meet the secondary lock again and run into a deadloop.
func NewClientHelper ¶
func NewClientHelper(store kvstore, resolvedLocks *util.TSSet, resolveLite bool) *ClientHelper
NewClientHelper creates a helper instance.
func (*ClientHelper) ResolveLocks ¶
func (ch *ClientHelper) ResolveLocks(bo *retry.Backoffer, callerStartTS uint64, locks []*txnlock.Lock) (int64, error)
ResolveLocks wraps the ResolveLocks function and store the resolved result.
func (*ClientHelper) SendReqCtx ¶
func (ch *ClientHelper) SendReqCtx(bo *retry.Backoffer, req *tikvrpc.Request, regionID locate.RegionVerID, timeout time.Duration, et tikvrpc.EndpointType, directStoreAddr string, opts ...locate.StoreSelectorOption) (*tikvrpc.Response, *locate.RPCContext, string, error)
SendReqCtx wraps the SendReqCtx function and use the resolved lock result in the kvrpcpb.Context.
type ConfigProbe ¶
type ConfigProbe struct{}
ConfigProbe exposes configurations and global variables for testing purpose.
func (ConfigProbe) GetGetMaxBackoff ¶
func (c ConfigProbe) GetGetMaxBackoff() int
GetGetMaxBackoff returns the max sleep for get command.
func (ConfigProbe) GetScanBatchSize ¶
func (c ConfigProbe) GetScanBatchSize() int
GetScanBatchSize returns the batch size to scan ranges.
type IsoLevel ¶
type IsoLevel kvrpcpb.IsolationLevel
IsoLevel is the transaction's isolation level.
const ( // SI stands for 'snapshot isolation'. SI IsoLevel = IsoLevel(kvrpcpb.IsolationLevel_SI) // RC stands for 'read committed'. RC IsoLevel = IsoLevel(kvrpcpb.IsolationLevel_RC) )
func (IsoLevel) ToPB ¶
func (l IsoLevel) ToPB() kvrpcpb.IsolationLevel
ToPB converts isolation level to wire type.
type KVSnapshot ¶
type KVSnapshot struct {
// contains filtered or unexported fields
}
KVSnapshot implements the tidbkv.Snapshot interface.
func NewTiKVSnapshot ¶
func NewTiKVSnapshot(store kvstore, ts uint64, replicaReadSeed uint32) *KVSnapshot
NewTiKVSnapshot creates a snapshot of an TiKV store.
func (*KVSnapshot) BatchGet ¶
BatchGet gets all the keys' value from kv-server and returns a map contains key/value pairs. The map will not contain nonexistent keys. NOTE: Don't modify keys. Some codes rely on the order of keys.
func (*KVSnapshot) Iter ¶
func (s *KVSnapshot) Iter(k []byte, upperBound []byte) (unionstore.Iterator, error)
Iter return a list of key-value pair after `k`.
func (*KVSnapshot) IterReverse ¶
func (s *KVSnapshot) IterReverse(k []byte) (unionstore.Iterator, error)
IterReverse creates a reversed Iterator positioned on the first entry which key is less than k.
func (*KVSnapshot) SetIsStatenessReadOnly ¶
func (s *KVSnapshot) SetIsStatenessReadOnly(b bool)
SetIsStatenessReadOnly indicates whether the transaction is staleness read only transaction
func (*KVSnapshot) SetIsolationLevel ¶
func (s *KVSnapshot) SetIsolationLevel(level IsoLevel)
SetIsolationLevel sets the isolation level used to scan data from tikv.
func (*KVSnapshot) SetKeyOnly ¶
func (s *KVSnapshot) SetKeyOnly(b bool)
SetKeyOnly indicates if tikv can return only keys.
func (*KVSnapshot) SetMatchStoreLabels ¶
func (s *KVSnapshot) SetMatchStoreLabels(labels []*metapb.StoreLabel)
SetMatchStoreLabels sets up labels to filter target stores.
func (*KVSnapshot) SetNotFillCache ¶
func (s *KVSnapshot) SetNotFillCache(b bool)
SetNotFillCache indicates whether tikv should skip filling cache when loading data.
func (*KVSnapshot) SetPriority ¶
func (s *KVSnapshot) SetPriority(pri txnutil.Priority)
SetPriority sets the priority for tikv to execute commands.
func (*KVSnapshot) SetReadReplicaScope ¶
func (s *KVSnapshot) SetReadReplicaScope(scope string)
SetReadReplicaScope set read replica scope
func (*KVSnapshot) SetReplicaRead ¶
func (s *KVSnapshot) SetReplicaRead(readType kv.ReplicaReadType)
SetReplicaRead sets up the replica read type.
func (*KVSnapshot) SetResourceGroupTag ¶
func (s *KVSnapshot) SetResourceGroupTag(tag []byte)
SetResourceGroupTag sets resource group of the kv request.
func (*KVSnapshot) SetRuntimeStats ¶
func (s *KVSnapshot) SetRuntimeStats(stats *SnapshotRuntimeStats)
SetRuntimeStats sets the stats to collect runtime statistics. Set it to nil to clear stored stats.
func (*KVSnapshot) SetSampleStep ¶
func (s *KVSnapshot) SetSampleStep(step uint32)
SetSampleStep skips 'step - 1' number of keys after each returned key.
func (*KVSnapshot) SetScanBatchSize ¶
func (s *KVSnapshot) SetScanBatchSize(batchSize int)
SetScanBatchSize sets the scan batchSize used to scan data from tikv.
func (*KVSnapshot) SetSnapshotTS ¶
func (s *KVSnapshot) SetSnapshotTS(ts uint64)
SetSnapshotTS resets the timestamp for reads.
func (*KVSnapshot) SetTaskID ¶
func (s *KVSnapshot) SetTaskID(id uint64)
SetTaskID marks current task's unique ID to allow TiKV to schedule tasks more fairly.
func (*KVSnapshot) SetTxnScope ¶
func (s *KVSnapshot) SetTxnScope(scope string)
SetTxnScope is same as SetReadReplicaScope, keep it in order to keep compatible for now.
func (*KVSnapshot) SetVars ¶
func (s *KVSnapshot) SetVars(vars *kv.Variables)
SetVars sets variables to the transaction.
func (*KVSnapshot) SnapCacheHitCount ¶
func (s *KVSnapshot) SnapCacheHitCount() int
SnapCacheHitCount gets the snapshot cache hit count. Only for test.
func (*KVSnapshot) SnapCacheSize ¶
func (s *KVSnapshot) SnapCacheSize() int
SnapCacheSize gets the snapshot cache size. Only for test.
type Scanner ¶
type Scanner struct {
// contains filtered or unexported fields
}
Scanner support tikv scan
type SnapshotProbe ¶
type SnapshotProbe struct {
*KVSnapshot
}
SnapshotProbe exposes some snapshot utilities for testing purpose.
func (SnapshotProbe) BatchGetSingleRegion ¶
func (s SnapshotProbe) BatchGetSingleRegion(bo *retry.Backoffer, region locate.RegionVerID, keys [][]byte, collectF func(k, v []byte)) error
BatchGetSingleRegion gets a batch of keys from a region.
func (SnapshotProbe) FormatStats ¶
func (s SnapshotProbe) FormatStats() string
FormatStats dumps information of stats.
func (SnapshotProbe) MergeExecDetail ¶
func (s SnapshotProbe) MergeExecDetail(detail *kvrpcpb.ExecDetailsV2)
MergeExecDetail merges exec stats into snapshot's stats.
func (SnapshotProbe) MergeRegionRequestStats ¶
func (s SnapshotProbe) MergeRegionRequestStats(stats map[tikvrpc.CmdType]*locate.RPCRuntimeStats)
MergeRegionRequestStats merges RPC runtime stats into snapshot's stats.
func (SnapshotProbe) NewScanner ¶
NewScanner returns a scanner to iterate given key range.
func (SnapshotProbe) RecordBackoffInfo ¶
func (s SnapshotProbe) RecordBackoffInfo(bo *retry.Backoffer)
RecordBackoffInfo records backoff stats into snapshot's stats.
type SnapshotRuntimeStats ¶
type SnapshotRuntimeStats struct {
// contains filtered or unexported fields
}
SnapshotRuntimeStats records the runtime stats of snapshot.
func (*SnapshotRuntimeStats) Clone ¶
func (rs *SnapshotRuntimeStats) Clone() *SnapshotRuntimeStats
Clone implements the RuntimeStats interface.
func (*SnapshotRuntimeStats) Merge ¶
func (rs *SnapshotRuntimeStats) Merge(other *SnapshotRuntimeStats)
Merge implements the RuntimeStats interface.
func (*SnapshotRuntimeStats) String ¶
func (rs *SnapshotRuntimeStats) String() string
String implements fmt.Stringer interface.