Struct tikv::server::lock_manager::deadlock::DetectTable [−][src]
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]
&mut self,
txn_ts: TimeStamp,
lock_ts: TimeStamp,
lock_hash: u64,
lock_key: &[u8],
resource_group_tag: &[u8]
) -> Option<(u64, Vec<WaitForEntry>)>
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]
&mut self,
txn_ts: TimeStamp,
wait_for_ts: TimeStamp
) -> Option<(u64, Vec<WaitForEntry>)>
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]
&self,
start: TimeStamp,
end: TimeStamp,
vertex_predecessors_map: HashMap<TimeStamp, TimeStamp>
) -> Vec<WaitForEntry>
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]
&mut self,
txn_ts: TimeStamp,
lock_ts: TimeStamp,
lock_hash: u64,
key: &[u8],
resource_group_tag: &[u8]
) -> bool
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]
&mut self,
txn_ts: TimeStamp,
lock_ts: TimeStamp,
lock_hash: u64,
key: &[u8],
resource_group_tag: &[u8]
)
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]
&mut self,
txn_ts: TimeStamp,
lock_ts: TimeStamp,
lock_hash: u64
)
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<V, W> ConvertFrom<W> for V where
W: ConvertTo<V>,
[src]
W: ConvertTo<V>,
pub fn convert_from(ctx: &mut EvalContext, from: W) -> Result<V, Error>
[src]
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Pointable for T
[src]
pub const ALIGN: usize
[src]
type Init = T
The type for initializers.
pub unsafe fn init(init: <T as Pointable>::Init) -> usize
[src]
pub unsafe fn deref<'a>(ptr: usize) -> &'a T
[src]
pub unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T
[src]
pub unsafe fn drop(ptr: usize)
[src]
impl<T> Pointable for T
[src]
pub const ALIGN: usize
[src]
type Init = T
The type for initializers.
pub unsafe fn init(init: <T as Pointable>::Init) -> usize
[src]
pub unsafe fn deref<'a>(ptr: usize) -> &'a T
[src]
pub unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T
[src]
pub unsafe fn drop(ptr: usize)
[src]
impl<T> Same<T> for T
[src]
type Output = T
Should always be Self
impl<T> Sealed<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> SendSyncUnwindSafe for T where
T: Send + Sync + UnwindSafe + ?Sized,
[src]
T: Send + Sync + UnwindSafe + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
[src]
V: MultiLane<T>,