Documentation ¶
Index ¶
- Constants
- Variables
- func DisableResourceControl()
- func EnableResourceControl()
- func GetStoreTypeByMeta(store *metapb.Store) tikvrpc.EndpointType
- func LoadShuttingDown() uint32
- func NewLockResolver(etcdAddrs []string, security config.Security, opts ...pd.ClientOption) (*txnlock.LockResolver, error)
- func NewPDClient(pdAddrs []string) (pd.Client, error)
- func NewRPCClient(opts ...ClientOpt) *client.RPCClient
- func NewRegionCache(pdClient pd.Client) *locate.RegionCache
- func RecordRegionRequestRuntimeStats(stats map[tikvrpc.CmdType]*locate.RPCRuntimeStats, cmd tikvrpc.CmdType, ...)
- func SetLogContextKey(key interface{})
- func SetRegionCacheTTLSec(t int64)
- func SetResourceControlInterceptor(interceptor resourceControlClient.ResourceGroupKVInterceptor)
- func SetStoreLivenessTimeout(t time.Duration)
- func StoreShuttingDown(v uint32)
- func TxnStartKey() interface{}
- func UnsetResourceControlInterceptor()
- func WithLogContext(ctx context.Context, logger *zap.Logger) context.Context
- type BackoffConfig
- type Backoffer
- type BinlogWriteResult
- type Client
- type ClientOpt
- type Codec
- type CodecClient
- type CodecPDClient
- type ConfigProbe
- func (c ConfigProbe) GetBigTxnThreshold() int
- func (c ConfigProbe) GetDefaultLockTTL() uint64
- func (c ConfigProbe) GetGetMaxBackoff() int
- func (c ConfigProbe) GetScanBatchSize() int
- func (c ConfigProbe) GetTTLFactor() int
- func (c ConfigProbe) GetTxnCommitBatchSize() uint64
- func (c ConfigProbe) LoadPreSplitDetectThreshold() uint32
- func (c ConfigProbe) LoadPreSplitSizeThreshold() uint32
- func (c ConfigProbe) SetOracleUpdateInterval(v int)
- func (c ConfigProbe) StorePreSplitDetectThreshold(v uint32)
- func (c ConfigProbe) StorePreSplitSizeThreshold(v uint32)
- type EtcdSafePointKV
- type Getter
- type Iterator
- type KVFilter
- type KVStore
- func (s *KVStore) Begin(opts ...TxnOption) (txn *transaction.KVTxn, err error)
- func (s *KVStore) BeginWithContext(ctx context.Context, opts ...TxnOption) (txn *transaction.KVTxn, err error)
- func (s *KVStore) CheckRegionInScattering(regionID uint64) (bool, error)
- func (s *KVStore) CheckVisibility(startTime uint64) error
- func (s *KVStore) Close() error
- func (s *KVStore) Closed() <-chan struct{}
- func (s *KVStore) Ctx() context.Context
- func (s *KVStore) CurrentTimestamp(txnScope string) (uint64, error)
- func (s *KVStore) DeleteRange(ctx context.Context, startKey []byte, endKey []byte, concurrency int) (completedRegions int, err error)
- func (s *KVStore) EnableTxnLocalLatches(size uint)
- func (s *KVStore) GC(ctx context.Context, safepoint uint64) (newSafePoint uint64, err error)
- func (s *KVStore) GetClusterID() uint64
- func (s *KVStore) GetLockResolver() *txnlock.LockResolver
- func (s *KVStore) GetMinSafeTS(txnScope string) uint64
- func (s *KVStore) GetOracle() oracle.Oracle
- func (s *KVStore) GetPDClient() pd.Client
- func (s *KVStore) GetRegionCache() *locate.RegionCache
- func (s *KVStore) GetSafePointKV() SafePointKV
- func (s *KVStore) GetSnapshot(ts uint64) *txnsnapshot.KVSnapshot
- func (s *KVStore) GetTiKVClient() (client Client)
- func (s *KVStore) GetTimestampWithRetry(bo *Backoffer, scope string) (uint64, error)
- func (s *KVStore) Go(f func())
- func (s *KVStore) IsClose() bool
- func (s *KVStore) IsLatchEnabled() bool
- func (s *KVStore) SendReq(bo *Backoffer, req *tikvrpc.Request, regionID locate.RegionVerID, ...) (*tikvrpc.Response, error)
- func (s *KVStore) SetOracle(oracle oracle.Oracle)
- func (s *KVStore) SetTiKVClient(client Client)
- func (s *KVStore) SplitRegions(ctx context.Context, splitKeys [][]byte, scatter bool, tableID *int64) (regionIDs []uint64, err error)
- func (s *KVStore) SupportDeleteRange() (supported bool)
- func (s *KVStore) TxnLatches() *latch.LatchesScheduler
- func (s *KVStore) UUID() string
- func (s *KVStore) UnsafeDestroyRange(ctx context.Context, startKey []byte, endKey []byte) error
- func (s *KVStore) UpdateSPCache(cachedSP uint64, cachedTime time.Time)
- func (s *KVStore) WaitGroup() *sync.WaitGroup
- func (s *KVStore) WaitScatterRegionFinish(ctx context.Context, regionID uint64, backOff int) error
- type KVTxn
- type KeyLocation
- type LockResolverProbe
- type MemDB
- type MemDBCheckpoint
- type MockSafePointKV
- type Mode
- type RPCCanceller
- type RPCCancellerCtxKey
- type RPCContext
- type RPCRuntimeStats
- type Region
- type RegionCache
- type RegionRequestRuntimeStats
- type RegionRequestSender
- type RegionVerID
- type SafePointKV
- type SchemaLeaseChecker
- type SchemaVer
- type Storage
- type Store
- type StoreProbe
- func (s StoreProbe) Begin() (transaction.TxnProbe, error)
- func (s StoreProbe) ClearTxnLatches()
- func (s StoreProbe) GetSnapshot(ts uint64) txnsnapshot.SnapshotProbe
- func (s StoreProbe) LoadSafePoint() (uint64, error)
- func (s StoreProbe) NewLockResolver() LockResolverProbe
- func (s StoreProbe) SaveSafePoint(v uint64) error
- func (s StoreProbe) SendTxnHeartbeat(ctx context.Context, key []byte, startTS uint64, ttl uint64) (uint64, error)
- func (s StoreProbe) SetRegionCachePDClient(client pd.Client)
- func (s StoreProbe) SetRegionCacheStore(id uint64, storeType tikvrpc.EndpointType, state uint64, ...)
- func (s StoreProbe) SetSafeTS(storeID, safeTS uint64)
- type StoreSelectorOption
- type TxnOption
- type Variables
Constants ¶
const ( ReadTimeoutMedium = client.ReadTimeoutMedium ReadTimeoutShort = client.ReadTimeoutShort MaxWriteExecutionTime = client.MaxWriteExecutionTime )
Timeout durations.
const ( // This is almost the same as 'tikv_gc_safe_point' in the table 'mysql.tidb', // save this to pd instead of tikv, because we can't use interface of table // if the safepoint on tidb is expired. GcSavedSafePoint = "/tidb/store/gcworker/saved_safe_point" GcSafePointCacheInterval = time.Second * 100 )
Safe point constants.
const DCLabelKey = "zone"
DCLabelKey indicates the key of label which represents the dc for Store.
const EpochNotMatch = locate.EpochNotMatch
EpochNotMatch indicates it's invalidated due to epoch not match
const MaxTxnTimeUse = transaction.MaxTxnTimeUse
MaxTxnTimeUse is the max time a Txn may use (in ms) from its begin to commit. We use it to abort the transaction to guarantee GC worker will not influence it.
Variables ¶
var DecodeKey = apicodec.DecodeKey
DecodeKey is used to split a given key to it's APIv2 prefix and actual key.
var DefaultKeyspaceID = apicodec.DefaultKeyspaceID
DefaultKeyspaceID is the keyspaceID of the default keyspace.
var DefaultKeyspaceName = apicodec.DefaultKeyspaceName
DefaultKeyspaceName is the name of the default keyspace.
var ( // EnableFailpoints enables use of failpoints. // It should be called before using client to avoid data race. EnableFailpoints = util.EnableFailpoints )
var NewCodecPDClient = locate.NewCodecPDClient
NewCodecPDClient is a constructor for CodecPDClient
var NewCodecPDClientWithKeyspace = locate.NewCodecPDClientWithKeyspace
NewCodecPDClientWithKeyspace creates a CodecPDClient in API v2 with keyspace name.
var NewCodecV1 = apicodec.NewCodecV1
NewCodecV1 is a constructor for v1 Codec.
var NewCodecV2 = apicodec.NewCodecV2
NewCodecV2 is a constructor for v2 Codec.
var NewNoopBackoff = retry.NewNoopBackoff
NewNoopBackoff create a Backoffer do nothing just return error directly
Functions ¶
func DisableResourceControl ¶
func DisableResourceControl()
DisableResourceControl disables the resource control.
func EnableResourceControl ¶
func EnableResourceControl()
EnableResourceControl enables the resource control.
func GetStoreTypeByMeta ¶
func GetStoreTypeByMeta(store *metapb.Store) tikvrpc.EndpointType
GetStoreTypeByMeta gets store type by store meta pb.
func LoadShuttingDown ¶
func LoadShuttingDown() uint32
LoadShuttingDown atomically loads ShuttingDown.
func NewLockResolver ¶
func NewLockResolver(etcdAddrs []string, security config.Security, opts ...pd.ClientOption) (*txnlock.LockResolver, error)
NewLockResolver creates a LockResolver. It is exported for other pkg to use. For instance, binlog service needs to determine a transaction's commit state. TODO(iosmanthus): support api v2
func NewPDClient ¶
NewPDClient returns an unwrapped pd client.
func NewRPCClient ¶
NewRPCClient creates a client that manages connections and rpc calls with tikv-servers.
func NewRegionCache ¶
func NewRegionCache(pdClient pd.Client) *locate.RegionCache
NewRegionCache creates a RegionCache.
func RecordRegionRequestRuntimeStats ¶
func RecordRegionRequestRuntimeStats(stats map[tikvrpc.CmdType]*locate.RPCRuntimeStats, cmd tikvrpc.CmdType, d time.Duration)
RecordRegionRequestRuntimeStats records request runtime stats.
func SetLogContextKey ¶
func SetLogContextKey(key interface{})
SetLogContextKey sets the context key which is used by client to retrieve *zap.Logger from context.
func SetRegionCacheTTLSec ¶
func SetRegionCacheTTLSec(t int64)
SetRegionCacheTTLSec sets regionCacheTTLSec to t.
func SetResourceControlInterceptor ¶
func SetResourceControlInterceptor(interceptor resourceControlClient.ResourceGroupKVInterceptor)
SetResourceControlInterceptor sets the interceptor for resource control.
func SetStoreLivenessTimeout ¶
SetStoreLivenessTimeout sets storeLivenessTimeout to t.
func StoreShuttingDown ¶
func StoreShuttingDown(v uint32)
StoreShuttingDown atomically stores ShuttingDown into v.
func TxnStartKey ¶
func TxnStartKey() interface{}
TxnStartKey is a key for transaction start_ts info in context.Context.
func UnsetResourceControlInterceptor ¶
func UnsetResourceControlInterceptor()
UnsetResourceControlInterceptor un-sets the interceptor for resource control.
Types ¶
type BackoffConfig ¶
BackoffConfig defines the backoff configuration.
func BoRegionMiss ¶
func BoRegionMiss() *BackoffConfig
BoRegionMiss returns the default backoff config for RegionMiss.
func BoTiFlashRPC ¶
func BoTiFlashRPC() *BackoffConfig
BoTiFlashRPC returns the default backoff config for TiFlashRPC.
func BoTiKVRPC ¶
func BoTiKVRPC() *BackoffConfig
BoTiKVRPC returns the default backoff config for TiKVRPC.
func BoTxnLock ¶
func BoTxnLock() *BackoffConfig
BoTxnLock returns the default backoff config for TxnLock.
type Backoffer ¶
Backoffer is a utility for retrying queries.
func NewBackoffer ¶
NewBackoffer creates a Backoffer with maximum sleep time(in ms).
func NewBackofferWithVars ¶
NewBackofferWithVars creates a Backoffer with maximum sleep time(in ms) and kv.Variables.
func NewGcResolveLockMaxBackoffer ¶
NewGcResolveLockMaxBackoffer creates a Backoffer for Gc to resolve lock.
type BinlogWriteResult ¶
type BinlogWriteResult = transaction.BinlogWriteResult
BinlogWriteResult defines the result of prewrite binlog.
type ClientOpt ¶
ClientOpt defines the option to create RPC client.
func WithSecurity ¶
WithSecurity is used to set security config.
type CodecClient ¶
type CodecClient struct { Client // contains filtered or unexported fields }
CodecClient warps Client to provide codec encode and decode.
type CodecPDClient ¶
type CodecPDClient = locate.CodecPDClient
CodecPDClient wraps a PD Client to decode the encoded keys in region meta.
type ConfigProbe ¶
type ConfigProbe struct{}
ConfigProbe exposes configurations and global variables for testing purpose.
func (ConfigProbe) GetBigTxnThreshold ¶
func (c ConfigProbe) GetBigTxnThreshold() int
GetBigTxnThreshold returns the txn size to be considered as big txn.
func (ConfigProbe) GetDefaultLockTTL ¶
func (c ConfigProbe) GetDefaultLockTTL() uint64
GetDefaultLockTTL returns the default lock TTL.
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.
func (ConfigProbe) GetTTLFactor ¶
func (c ConfigProbe) GetTTLFactor() int
GetTTLFactor returns the factor to calculate txn TTL.
func (ConfigProbe) GetTxnCommitBatchSize ¶
func (c ConfigProbe) GetTxnCommitBatchSize() uint64
GetTxnCommitBatchSize returns the batch size to commit txn.
func (ConfigProbe) LoadPreSplitDetectThreshold ¶
func (c ConfigProbe) LoadPreSplitDetectThreshold() uint32
LoadPreSplitDetectThreshold returns presplit detect threshold config.
func (ConfigProbe) LoadPreSplitSizeThreshold ¶
func (c ConfigProbe) LoadPreSplitSizeThreshold() uint32
LoadPreSplitSizeThreshold returns presplit size threshold config.
func (ConfigProbe) SetOracleUpdateInterval ¶
func (c ConfigProbe) SetOracleUpdateInterval(v int)
SetOracleUpdateInterval sets the interval of updating cached ts.
func (ConfigProbe) StorePreSplitDetectThreshold ¶
func (c ConfigProbe) StorePreSplitDetectThreshold(v uint32)
StorePreSplitDetectThreshold updates presplit detect threshold config.
func (ConfigProbe) StorePreSplitSizeThreshold ¶
func (c ConfigProbe) StorePreSplitSizeThreshold(v uint32)
StorePreSplitSizeThreshold updates presplit size threshold config.
type EtcdSafePointKV ¶
type EtcdSafePointKV struct {
// contains filtered or unexported fields
}
EtcdSafePointKV implements SafePointKV at runtime
func NewEtcdSafePointKV ¶
func NewEtcdSafePointKV(addrs []string, tlsConfig *tls.Config) (*EtcdSafePointKV, error)
NewEtcdSafePointKV creates an instance of EtcdSafePointKV
func (*EtcdSafePointKV) Close ¶
func (w *EtcdSafePointKV) Close() error
Close implements the Close for SafePointKV
func (*EtcdSafePointKV) Get ¶
func (w *EtcdSafePointKV) Get(k string) (string, error)
Get implements the Get method for SafePointKV
func (*EtcdSafePointKV) GetWithPrefix ¶
func (w *EtcdSafePointKV) GetWithPrefix(k string) ([]*mvccpb.KeyValue, error)
GetWithPrefix implements the GetWithPrefix for SafePointKV
type Iterator ¶
type Iterator = unionstore.Iterator
Iterator is the interface for a iterator on KV store.
type KVFilter ¶
type KVFilter = transaction.KVFilter
KVFilter is a filter that filters out unnecessary KV pairs.
type KVStore ¶
type KVStore struct {
// contains filtered or unexported fields
}
KVStore contains methods to interact with a TiKV cluster.
func NewKVStore ¶
func NewKVStore(uuid string, pdClient pd.Client, spkv SafePointKV, tikvclient Client) (*KVStore, error)
NewKVStore creates a new TiKV store instance.
func NewTestTiKVStore ¶
func NewTestTiKVStore(client Client, pdClient pd.Client, clientHijack func(Client) Client, pdClientHijack func(pd.Client) pd.Client, txnLocalLatches uint) (*KVStore, error)
NewTestTiKVStore creates a test store with Option
func (*KVStore) Begin ¶
func (s *KVStore) Begin(opts ...TxnOption) (txn *transaction.KVTxn, err error)
Begin a global transaction.
func (*KVStore) BeginWithContext ¶
func (*KVStore) CheckRegionInScattering ¶
CheckRegionInScattering uses to check whether scatter region finished.
func (*KVStore) CheckVisibility ¶
CheckVisibility checks if it is safe to read using given ts.
func (*KVStore) Closed ¶
func (s *KVStore) Closed() <-chan struct{}
Closed returns a channel that indicates if the store is closed.
func (*KVStore) CurrentTimestamp ¶
CurrentTimestamp returns current timestamp with the given txnScope (local or global).
func (*KVStore) DeleteRange ¶
func (s *KVStore) DeleteRange(ctx context.Context, startKey []byte, endKey []byte, concurrency int) (completedRegions int, err error)
DeleteRange delete all versions of all keys in the range[startKey,endKey) immediately. Be careful while using this API. This API doesn't keep recent MVCC versions, but will delete all versions of all keys in the range immediately. Also notice that frequent invocation to this API may cause performance problems to TiKV.
func (*KVStore) EnableTxnLocalLatches ¶
EnableTxnLocalLatches enables txn latch. It should be called before using the store to serve any requests.
func (*KVStore) GC ¶
GC does garbage collection (GC) of the TiKV cluster. GC deletes MVCC records whose timestamp is lower than the given `safepoint`. We must guarantee
that all transactions started before this timestamp had committed. We can keep an active
transaction list in application to decide which is the minimal start timestamp of them.
For each key, the last mutation record (unless it's a deletion) before `safepoint` is retained.
GC is performed by: 1. resolving all locks with timestamp <= `safepoint` 2. updating PD's known safepoint
GC is a simplified version of [GC in TiDB](https://docs.pingcap.com/tidb/stable/garbage-collection-overview). We skip the second step "delete ranges" which is an optimization for TiDB.
func (*KVStore) GetClusterID ¶
GetClusterID returns store's cluster id.
func (*KVStore) GetLockResolver ¶
func (s *KVStore) GetLockResolver() *txnlock.LockResolver
GetLockResolver returns the lock resolver instance.
func (*KVStore) GetMinSafeTS ¶
GetMinSafeTS return the minimal safeTS of the storage with given txnScope.
func (*KVStore) GetPDClient ¶
GetPDClient returns the PD client.
func (*KVStore) GetRegionCache ¶
func (s *KVStore) GetRegionCache() *locate.RegionCache
GetRegionCache returns the region cache instance.
func (*KVStore) GetSafePointKV ¶
func (s *KVStore) GetSafePointKV() SafePointKV
GetSafePointKV returns the kv store that used for safepoint.
func (*KVStore) GetSnapshot ¶
func (s *KVStore) GetSnapshot(ts uint64) *txnsnapshot.KVSnapshot
GetSnapshot gets a snapshot that is able to read any data which data is <= the given ts. If the given ts is greater than the current TSO timestamp, the snapshot is not guaranteed to be consistent. Specially, it is useful to set ts to math.MaxUint64 to point get the latest committed data.
func (*KVStore) GetTiKVClient ¶
GetTiKVClient gets the client instance.
func (*KVStore) GetTimestampWithRetry ¶
GetTimestampWithRetry returns latest timestamp.
func (*KVStore) IsLatchEnabled ¶
IsLatchEnabled is used by mockstore.TestConfig.
func (*KVStore) SendReq ¶
func (s *KVStore) SendReq(bo *Backoffer, req *tikvrpc.Request, regionID locate.RegionVerID, timeout time.Duration) (*tikvrpc.Response, error)
SendReq sends a request to locate.
func (*KVStore) SetTiKVClient ¶
SetTiKVClient resets the client instance.
func (*KVStore) SplitRegions ¶
func (s *KVStore) SplitRegions(ctx context.Context, splitKeys [][]byte, scatter bool, tableID *int64) (regionIDs []uint64, err error)
SplitRegions splits regions by splitKeys.
func (*KVStore) SupportDeleteRange ¶
SupportDeleteRange gets the storage support delete range or not.
func (*KVStore) TxnLatches ¶
func (s *KVStore) TxnLatches() *latch.LatchesScheduler
TxnLatches returns txnLatches.
func (*KVStore) UnsafeDestroyRange ¶
UnsafeDestroyRange Cleans up all keys in a range[startKey,endKey) and quickly free the disk space. The range might span over multiple regions, and the `ctx` doesn't indicate region. The request will be done directly on RocksDB, bypassing the Raft layer. User must promise that, after calling `UnsafeDestroyRange`, the range will never be accessed any more. However, `UnsafeDestroyRange` is allowed to be called multiple times on an single range.
func (*KVStore) UpdateSPCache ¶
UpdateSPCache updates cached safepoint.
func (*KVStore) WaitScatterRegionFinish ¶
WaitScatterRegionFinish implements SplittableStore interface. backOff is the back off time of the wait scatter region.(Milliseconds) if backOff <= 0, the default wait scatter back off time will be used.
type KVTxn ¶
type KVTxn = transaction.KVTxn
KVTxn contains methods to interact with a TiKV transaction.
type KeyLocation ¶
type KeyLocation = locate.KeyLocation
KeyLocation is the region and range that a key is located.
type LockResolverProbe ¶
type LockResolverProbe struct {
*txnlock.LockResolverProbe
}
LockResolverProbe wraps a LockResolver and exposes internal stats for testing purpose.
func NewLockResolverProb ¶
func NewLockResolverProb(r *txnlock.LockResolver) *LockResolverProbe
NewLockResolverProb create a LockResolverProbe from KVStore.
func (LockResolverProbe) ForceResolveLock ¶
ForceResolveLock forces to resolve a single lock. It's a helper function only for writing test.
func (LockResolverProbe) ResolveLock ¶
ResolveLock resolves single lock.
func (LockResolverProbe) ResolvePessimisticLock ¶
ResolvePessimisticLock resolves single pessimistic lock.
type MemDB ¶
type MemDB = unionstore.MemDB
MemDB is rollbackable Red-Black Tree optimized for transaction states buffer use scenario. You can think MemDB is a combination of two separate tree map, one for key => value and another for key => keyFlags.
The value map is rollbackable, that means you can use the `Staging`, `Release` and `Cleanup` API to safely modify KVs.
The flags map is not rollbackable. There are two types of flag, persistent and non-persistent. When discarding a newly added KV in `Cleanup`, the non-persistent flags will be cleared. If there are persistent flags associated with key, we will keep this key in node without value.
type MemDBCheckpoint ¶
type MemDBCheckpoint = unionstore.MemDBCheckpoint
MemDBCheckpoint is the checkpoint of memory DB.
type MockSafePointKV ¶
type MockSafePointKV struct {
// contains filtered or unexported fields
}
MockSafePointKV implements SafePointKV at mock test
func NewMockSafePointKV ¶
func NewMockSafePointKV() *MockSafePointKV
NewMockSafePointKV creates an instance of MockSafePointKV
func (*MockSafePointKV) Close ¶
func (w *MockSafePointKV) Close() error
Close implements the Close method for SafePointKV
func (*MockSafePointKV) Get ¶
func (w *MockSafePointKV) Get(k string) (string, error)
Get implements the Get method for SafePointKV
func (*MockSafePointKV) GetWithPrefix ¶
func (w *MockSafePointKV) GetWithPrefix(prefix string) ([]*mvccpb.KeyValue, error)
GetWithPrefix implements the Get method for SafePointKV
type RPCCanceller ¶
type RPCCanceller = locate.RPCCanceller
RPCCanceller is rpc send cancelFunc collector.
func NewRPCanceller ¶
func NewRPCanceller() *RPCCanceller
NewRPCanceller creates RPCCanceller with init state.
type RPCCancellerCtxKey ¶
type RPCCancellerCtxKey = locate.RPCCancellerCtxKey
RPCCancellerCtxKey is context key attach rpc send cancelFunc collector to ctx.
type RPCContext ¶
type RPCContext = locate.RPCContext
RPCContext contains data that is needed to send RPC to a region.
type RPCRuntimeStats ¶
type RPCRuntimeStats = locate.RPCRuntimeStats
RPCRuntimeStats indicates the RPC request count and consume time.
type RegionRequestRuntimeStats ¶
type RegionRequestRuntimeStats = locate.RegionRequestRuntimeStats
RegionRequestRuntimeStats records the runtime stats of send region requests.
func NewRegionRequestRuntimeStats ¶
func NewRegionRequestRuntimeStats() RegionRequestRuntimeStats
NewRegionRequestRuntimeStats returns a new RegionRequestRuntimeStats.
type RegionRequestSender ¶
type RegionRequestSender = locate.RegionRequestSender
RegionRequestSender sends KV/Cop requests to tikv server. It handles network errors and some region errors internally.
Typically, a KV/Cop request is bind to a region, all keys that are involved in the request should be located in the region. The sending process begins with looking for the address of leader store's address of the target region from cache, and the request is then sent to the destination tikv server over TCP connection. If region is updated, can be caused by leader transfer, region split, region merge, or region balance, tikv server may not able to process request and send back a RegionError. RegionRequestSender takes care of errors that does not relevant to region range, such as 'I/O timeout', 'NotLeader', and 'ServerIsBusy'. For other errors, since region range have changed, the request may need to split, so we simply return the error to caller.
func NewRegionRequestSender ¶
func NewRegionRequestSender(regionCache *RegionCache, client client.Client) *RegionRequestSender
NewRegionRequestSender creates a new sender.
type RegionVerID ¶
type RegionVerID = locate.RegionVerID
RegionVerID is a unique ID that can identify a Region at a specific version.
func NewRegionVerID ¶
func NewRegionVerID(id, confVer, ver uint64) RegionVerID
NewRegionVerID creates a region ver id, which used for invalidating regions.
type SafePointKV ¶
type SafePointKV interface { Put(k string, v string) error Get(k string) (string, error) GetWithPrefix(k string) ([]*mvccpb.KeyValue, error) Close() error }
SafePointKV is used for a seamingless integration for mockTest and runtime.
type SchemaLeaseChecker ¶
type SchemaLeaseChecker = transaction.SchemaLeaseChecker
SchemaLeaseChecker is used to validate schema version is not changed during transaction execution.
type SchemaVer ¶
type SchemaVer = transaction.SchemaVer
SchemaVer is the infoSchema which will return the schema version.
type Storage ¶
type Storage interface { // GetRegionCache gets the RegionCache. GetRegionCache() *locate.RegionCache // SendReq sends a request to TiKV. SendReq(bo *Backoffer, req *tikvrpc.Request, regionID locate.RegionVerID, timeout time.Duration) (*tikvrpc.Response, error) // GetLockResolver gets the LockResolver. GetLockResolver() *txnlock.LockResolver // GetSafePointKV gets the SafePointKV. GetSafePointKV() SafePointKV // UpdateSPCache updates the cache of safe point. UpdateSPCache(cachedSP uint64, cachedTime time.Time) // SetOracle sets the Oracle. SetOracle(oracle oracle.Oracle) // SetTiKVClient sets the TiKV client. SetTiKVClient(client Client) // GetTiKVClient gets the TiKV client. GetTiKVClient() Client // Closed returns the closed channel. Closed() <-chan struct{} // Close store Close() error // UUID return a unique ID which represents a Storage. UUID() string // CurrentTimestamp returns current timestamp with the given txnScope (local or global). CurrentTimestamp(txnScope string) (uint64, error) // GetOracle gets a timestamp oracle client. GetOracle() oracle.Oracle // SupportDeleteRange gets the storage support delete range or not. SupportDeleteRange() (supported bool) }
Storage represent the kv.Storage runs on TiKV.
type StoreProbe ¶
type StoreProbe struct {
*KVStore
}
StoreProbe wraps KVSTore and exposes internal states for testing purpose.
func (StoreProbe) Begin ¶
func (s StoreProbe) Begin() (transaction.TxnProbe, error)
Begin starts a transaction.
func (StoreProbe) ClearTxnLatches ¶
func (s StoreProbe) ClearTxnLatches()
ClearTxnLatches clears store's txn latch scheduler.
func (StoreProbe) GetSnapshot ¶
func (s StoreProbe) GetSnapshot(ts uint64) txnsnapshot.SnapshotProbe
GetSnapshot returns a snapshot.
func (StoreProbe) LoadSafePoint ¶
func (s StoreProbe) LoadSafePoint() (uint64, error)
LoadSafePoint from safepoint kv.
func (StoreProbe) NewLockResolver ¶
func (s StoreProbe) NewLockResolver() LockResolverProbe
NewLockResolver creates a new LockResolver instance.
func (StoreProbe) SaveSafePoint ¶
func (s StoreProbe) SaveSafePoint(v uint64) error
SaveSafePoint saves safepoint to kv.
func (StoreProbe) SendTxnHeartbeat ¶
func (s StoreProbe) SendTxnHeartbeat(ctx context.Context, key []byte, startTS uint64, ttl uint64) (uint64, error)
SendTxnHeartbeat renews a txn's ttl.
func (StoreProbe) SetRegionCachePDClient ¶
func (s StoreProbe) SetRegionCachePDClient(client pd.Client)
SetRegionCachePDClient replaces pd client inside region cache.
func (StoreProbe) SetRegionCacheStore ¶
func (s StoreProbe) SetRegionCacheStore(id uint64, storeType tikvrpc.EndpointType, state uint64, labels []*metapb.StoreLabel)
SetRegionCacheStore is used to set a store in region cache, for testing only
func (StoreProbe) SetSafeTS ¶
func (s StoreProbe) SetSafeTS(storeID, safeTS uint64)
SetSafeTS is used to set safeTS for the store with `storeID`
type StoreSelectorOption ¶
type StoreSelectorOption = locate.StoreSelectorOption
StoreSelectorOption configures storeSelectorOp.
func WithMatchLabels ¶
func WithMatchLabels(labels []*metapb.StoreLabel) StoreSelectorOption
WithMatchLabels indicates selecting stores with matched labels
type TxnOption ¶
type TxnOption func(*transaction.TxnOptions)
TxnOption configures Transaction
func WithDisableKeepAlive ¶
WithDisableKeepAlive sets the DisableKeepAlive to true
func WithLifetime ¶
WithLifetime sets the LifetimeMs to lifetimeMs
func WithStartTS ¶
WithStartTS sets the StartTS to startTS
func WithTxnScope ¶
WithTxnScope sets the TxnScope to txnScope