Struct tikv::server::lock_manager::deadlock::DetectTable[][src]

pub struct DetectTable {
    wait_for_map: HashMap<TimeStamp, HashMap<TimeStamp, Locks>>,
    ttl: Duration,
    last_active_expire: Instant,
    now: Instant,
}

Used to detect the deadlock of wait-for-lock in the cluster.

Fields

wait_for_map: HashMap<TimeStamp, HashMap<TimeStamp, Locks>>

Keeps the DAG of wait-for-lock. Every edge from txn_ts to lock_ts has a survival time – ttl. When checking the deadlock, if the ttl has elpased, the corresponding edge will be removed. last_detect_time is the start time of the edge. Detect requests will refresh it.

ttl: Duration

The ttl of every edge.

last_active_expire: Instant

The time of last active_expire.

now: Instant

Implementations

impl DetectTable[src]

pub fn new(ttl: Duration) -> Self[src]

Creates a auto-expiring detect table.

pub fn detect(
    &mut self,
    txn_ts: TimeStamp,
    lock_ts: TimeStamp,
    lock_hash: u64,
    lock_key: &[u8],
    resource_group_tag: &[u8]
) -> Option<(u64, Vec<WaitForEntry>)>
[src]

Returns the key hash which causes deadlock, and the current wait chain that forms the deadlock with txn_ts’s waiting for txn at lock_ts. Note that the current detecting edge is not included in the returned wait chain. This is intended to reduce RPC message size since the information about current detecting txn is included in a separated field.

fn do_detect(
    &mut self,
    txn_ts: TimeStamp,
    wait_for_ts: TimeStamp
) -> Option<(u64, Vec<WaitForEntry>)>
[src]

Checks if there is a path from wait_for_ts to txn_ts.

fn generate_wait_chain(
    &self,
    start: TimeStamp,
    end: TimeStamp,
    vertex_predecessors_map: HashMap<TimeStamp, TimeStamp>
) -> Vec<WaitForEntry>
[src]

Generate the wait chain after deadlock is detected. This function is part of implementation of do_detect. It assumes there’s a path from start to end in the waiting graph, and every single edge V1 -> V2 has an entry in vertex_predecessors_map so that vertex_predecessors_map[V2] == V1, and vertex_predecessors_map[V1] == 0.

fn register_if_existed(
    &mut self,
    txn_ts: TimeStamp,
    lock_ts: TimeStamp,
    lock_hash: u64,
    key: &[u8],
    resource_group_tag: &[u8]
) -> bool
[src]

Returns true and adds to the detect table if txn_ts is waiting for lock_ts. When the function returns true, key and resource_group_tag may be taken to store in the waiting graph.

fn register(
    &mut self,
    txn_ts: TimeStamp,
    lock_ts: TimeStamp,
    lock_hash: u64,
    key: &[u8],
    resource_group_tag: &[u8]
)
[src]

Adds to the detect table. The edge from txn_ts to lock_ts must not exist.

fn clean_up_wait_for(
    &mut self,
    txn_ts: TimeStamp,
    lock_ts: TimeStamp,
    lock_hash: u64
)
[src]

Removes the corresponding wait_for_entry.

fn clean_up(&mut self, txn_ts: TimeStamp)[src]

Removes the entries of the transaction.

fn clear(&mut self)[src]

Clears the whole detect table.

fn reset_ttl(&mut self, ttl: Duration)[src]

Reset the ttl

const ACTIVE_EXPIRE_THRESHOLD: usize[src]

The threshold of detect table size to trigger active_expire.

const ACTIVE_EXPIRE_INTERVAL: Duration[src]

The interval between active_expire.

fn active_expire(&mut self)[src]

Iterates the whole table to remove all expired entries.

Auto Trait Implementations

impl RefUnwindSafe for DetectTable

impl Send for DetectTable

impl Sync for DetectTable

impl Unpin for DetectTable

impl UnwindSafe for DetectTable

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<V, W> ConvertFrom<W> for V where
    W: ConvertTo<V>, 
[src]

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Pointable for T[src]

type Init = T

The type for initializers.

impl<T> Pointable for T[src]

type Init = T

The type for initializers.

impl<T> Same<T> for T[src]

type Output = T

Should always be Self

impl<T> Sealed<T> for T where
    T: ?Sized
[src]

impl<T> SendSyncUnwindSafe for T where
    T: Send + Sync + UnwindSafe + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 
[src]