tikv

package
v2.0.0-...-439aceb Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 15, 2023 License: Apache-2.0 Imports: 46 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ReadTimeoutMedium     = client.ReadTimeoutMedium
	ReadTimeoutShort      = client.ReadTimeoutShort
	MaxWriteExecutionTime = client.MaxWriteExecutionTime
)

Timeout durations.

View Source
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.

View Source
const DCLabelKey = "zone"

DCLabelKey indicates the key of label which represents the dc for Store.

View Source
const EpochNotMatch = locate.EpochNotMatch

EpochNotMatch indicates it's invalidated due to epoch not match

View Source
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

View Source
var DecodeKey = apicodec.DecodeKey

DecodeKey is used to split a given key to it's APIv2 prefix and actual key.

View Source
var DefaultKeyspaceID = apicodec.DefaultKeyspaceID

DefaultKeyspaceID is the keyspaceID of the default keyspace.

View Source
var DefaultKeyspaceName = apicodec.DefaultKeyspaceName

DefaultKeyspaceName is the name of the default keyspace.

View Source
var (
	// EnableFailpoints enables use of failpoints.
	// It should be called before using client to avoid data race.
	EnableFailpoints = util.EnableFailpoints
)
View Source
var NewCodecPDClient = locate.NewCodecPDClient

NewCodecPDClient is a constructor for CodecPDClient

View Source
var NewCodecPDClientWithKeyspace = locate.NewCodecPDClientWithKeyspace

NewCodecPDClientWithKeyspace creates a CodecPDClient in API v2 with keyspace name.

View Source
var NewCodecV1 = apicodec.NewCodecV1

NewCodecV1 is a constructor for v1 Codec.

View Source
var NewCodecV2 = apicodec.NewCodecV2

NewCodecV2 is a constructor for v2 Codec.

View Source
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

func NewPDClient(pdAddrs []string) (pd.Client, error)

NewPDClient returns an unwrapped pd client.

func NewRPCClient

func NewRPCClient(opts ...ClientOpt) *client.RPCClient

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

func SetStoreLivenessTimeout(t time.Duration)

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.

func WithLogContext

func WithLogContext(ctx context.Context, logger *zap.Logger) context.Context

WithLogContext returns a copy of context that is associated with a logger.

Types

type BackoffConfig

type BackoffConfig = retry.Config

BackoffConfig defines the backoff configuration.

func BoPDRPC

func BoPDRPC() *BackoffConfig

BoPDRPC returns the default backoff config for PDRPC.

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

type Backoffer = retry.Backoffer

Backoffer is a utility for retrying queries.

func NewBackoffer

func NewBackoffer(ctx context.Context, maxSleep int) *Backoffer

NewBackoffer creates a Backoffer with maximum sleep time(in ms).

func NewBackofferWithVars

func NewBackofferWithVars(ctx context.Context, maxSleep int, vars *kv.Variables) *Backoffer

NewBackofferWithVars creates a Backoffer with maximum sleep time(in ms) and kv.Variables.

func NewGcResolveLockMaxBackoffer

func NewGcResolveLockMaxBackoffer(ctx context.Context) *Backoffer

NewGcResolveLockMaxBackoffer creates a Backoffer for Gc to resolve lock.

type BinlogWriteResult

type BinlogWriteResult = transaction.BinlogWriteResult

BinlogWriteResult defines the result of prewrite binlog.

type Client

type Client = client.Client

Client is a client that sends RPC. It should not be used after calling Close().

type ClientOpt

type ClientOpt = client.Opt

ClientOpt defines the option to create RPC client.

func WithCodec

func WithCodec(codec apicodec.Codec) ClientOpt

WithCodec is used to set client codec.

func WithSecurity

func WithSecurity(security config.Security) ClientOpt

WithSecurity is used to set security config.

type Codec

type Codec = apicodec.Codec

Codec is responsible for encode/decode requests.

type CodecClient

type CodecClient struct {
	Client
	// contains filtered or unexported fields
}

CodecClient warps Client to provide codec encode and decode.

func (*CodecClient) SendRequest

func (c *CodecClient) SendRequest(ctx context.Context, addr string, req *tikvrpc.Request, timeout time.Duration) (*tikvrpc.Response, error)

SendRequest uses codec to encode request before send, and decode response before return.

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

func (*EtcdSafePointKV) Put

func (w *EtcdSafePointKV) Put(k string, v string) error

Put implements the Put method for SafePointKV

type Getter

type Getter = unionstore.Getter

Getter is the interface for the Get method.

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 (s *KVStore) BeginWithContext(ctx context.Context, opts ...TxnOption) (txn *transaction.KVTxn, err error)

func (*KVStore) CheckRegionInScattering

func (s *KVStore) CheckRegionInScattering(regionID uint64) (bool, error)

CheckRegionInScattering uses to check whether scatter region finished.

func (*KVStore) CheckVisibility

func (s *KVStore) CheckVisibility(startTime uint64) error

CheckVisibility checks if it is safe to read using given ts.

func (*KVStore) Close

func (s *KVStore) Close() error

Close store

func (*KVStore) Closed

func (s *KVStore) Closed() <-chan struct{}

Closed returns a channel that indicates if the store is closed.

func (*KVStore) Ctx

func (s *KVStore) Ctx() context.Context

Ctx returns ctx.

func (*KVStore) CurrentTimestamp

func (s *KVStore) CurrentTimestamp(txnScope string) (uint64, error)

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

func (s *KVStore) EnableTxnLocalLatches(size uint)

EnableTxnLocalLatches enables txn latch. It should be called before using the store to serve any requests.

func (*KVStore) GC

func (s *KVStore) GC(ctx context.Context, safepoint uint64) (newSafePoint uint64, err error)

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

func (s *KVStore) GetClusterID() uint64

GetClusterID returns store's cluster id.

func (*KVStore) GetLockResolver

func (s *KVStore) GetLockResolver() *txnlock.LockResolver

GetLockResolver returns the lock resolver instance.

func (*KVStore) GetMinSafeTS

func (s *KVStore) GetMinSafeTS(txnScope string) uint64

GetMinSafeTS return the minimal safeTS of the storage with given txnScope.

func (*KVStore) GetOracle

func (s *KVStore) GetOracle() oracle.Oracle

GetOracle gets a timestamp oracle client.

func (*KVStore) GetPDClient

func (s *KVStore) GetPDClient() pd.Client

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

func (s *KVStore) GetTiKVClient() (client Client)

GetTiKVClient gets the client instance.

func (*KVStore) GetTimestampWithRetry

func (s *KVStore) GetTimestampWithRetry(bo *Backoffer, scope string) (uint64, error)

GetTimestampWithRetry returns latest timestamp.

func (*KVStore) Go

func (s *KVStore) Go(f func())

Go run the function in a separate goroutine.

func (*KVStore) IsClose

func (s *KVStore) IsClose() bool

IsClose checks whether the store is closed.

func (*KVStore) IsLatchEnabled

func (s *KVStore) IsLatchEnabled() bool

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) SetOracle

func (s *KVStore) SetOracle(oracle oracle.Oracle)

SetOracle resets the oracle instance.

func (*KVStore) SetTiKVClient

func (s *KVStore) SetTiKVClient(client Client)

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

func (s *KVStore) SupportDeleteRange() (supported bool)

SupportDeleteRange gets the storage support delete range or not.

func (*KVStore) TxnLatches

func (s *KVStore) TxnLatches() *latch.LatchesScheduler

TxnLatches returns txnLatches.

func (*KVStore) UUID

func (s *KVStore) UUID() string

UUID return a unique ID which represents a Storage.

func (*KVStore) UnsafeDestroyRange

func (s *KVStore) UnsafeDestroyRange(ctx context.Context, startKey []byte, endKey []byte) error

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

func (s *KVStore) UpdateSPCache(cachedSP uint64, cachedTime time.Time)

UpdateSPCache updates cached safepoint.

func (*KVStore) WaitGroup

func (s *KVStore) WaitGroup() *sync.WaitGroup

WaitGroup returns wg

func (*KVStore) WaitScatterRegionFinish

func (s *KVStore) WaitScatterRegionFinish(ctx context.Context, regionID uint64, backOff int) error

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

func (l LockResolverProbe) ForceResolveLock(ctx context.Context, lock *txnlock.Lock) error

ForceResolveLock forces to resolve a single lock. It's a helper function only for writing test.

func (LockResolverProbe) ResolveLock

func (l LockResolverProbe) ResolveLock(ctx context.Context, lock *txnlock.Lock) error

ResolveLock resolves single lock.

func (LockResolverProbe) ResolvePessimisticLock

func (l LockResolverProbe) ResolvePessimisticLock(ctx context.Context, lock *txnlock.Lock) error

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

func (*MockSafePointKV) Put

func (w *MockSafePointKV) Put(k string, v string) error

Put implements the Put method for SafePointKV

type Mode

type Mode = apicodec.Mode

Mode represents the operation mode of a request, export client.Mode

var (
	// ModeRaw represent a raw operation in TiKV, export client.ModeRaw
	ModeRaw Mode = apicodec.ModeRaw

	// ModeTxn represent a transaction operation in TiKV, export client.ModeTxn
	ModeTxn Mode = apicodec.ModeTxn
)

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 Region

type Region = locate.Region

Region presents kv region

type RegionCache

type RegionCache = locate.RegionCache

RegionCache caches Regions loaded from PD.

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 Store

type Store = locate.Store

Store contains a kv process's address.

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

func WithDisableKeepAlive(disableKeepAlive bool) TxnOption

WithDisableKeepAlive sets the DisableKeepAlive to true

func WithLifetime

func WithLifetime(lifetimeMs uint64) TxnOption

WithLifetime sets the LifetimeMs to lifetimeMs

func WithStartTS

func WithStartTS(startTS uint64) TxnOption

WithStartTS sets the StartTS to startTS

func WithTxnScope

func WithTxnScope(txnScope string) TxnOption

WithTxnScope sets the TxnScope to txnScope

type Variables

type Variables = kv.Variables

Variables defines the variables used by TiKV storage.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL