pub enum LockType {
Read,
Write,
RangeRead,
RangeWrite,
RangeInsert,
None,
Restart,
}Expand description
Lock types used in the transaction system.
Noxu DB uses hierarchical locking with five primary lock types. The conflict and upgrade matrices define how locks interact.
Variants§
Read
Basic read lock on a record.
Allows multiple concurrent readers but blocks writers.
Write
Write lock on a record (exclusive).
Blocks all other lockers from reading or writing this record.
RangeRead
Range read lock - locks a range to prevent phantom inserts.
Similar to Read but also prevents inserts into the range.
RangeWrite
Range write lock - combines range and write locking.
Blocks all access and prevents inserts into the range.
RangeInsert
Range insert lock - used when inserting into a range.
Conflicts with range locks to trigger restart on phantom detection.
None
No lock requested (dirty read).
Special type indicating no locking should be performed.
Restart
Restart marker - not a real lock type.
Used internally to indicate a range restart is needed.
Implementations§
Source§impl LockType
impl LockType
Sourcepub fn is_write_lock(self) -> bool
pub fn is_write_lock(self) -> bool
Returns true if this is a write lock that modifies data.
Note: Per implementation, RangeInsert is NOT considered a write lock for the purposes of transaction commit/abort. Only Write and RangeWrite require undo information.
Sourcepub fn causes_restart(self) -> bool
pub fn causes_restart(self) -> bool
Returns true if this lock type causes a restart when upgraded.
RangeRead and RangeWrite cause restarts in certain upgrade scenarios.
Sourcepub fn get_conflict(self, requested: LockType) -> LockConflict
pub fn get_conflict(self, requested: LockType) -> LockConflict
Returns the conflict status between a held lock and a requested lock.
This implements the 5x5 conflict matrix from the:
READ WRITE RANGE_R RANGE_W RANGE_I
READ ALLOW BLOCK ALLOW BLOCK ALLOW
WRITE BLOCK BLOCK BLOCK BLOCK ALLOW
RANGE_READ ALLOW BLOCK ALLOW BLOCK BLOCK
RANGE_WRITE BLOCK BLOCK BLOCK BLOCK BLOCK
RANGE_INS ALLOW ALLOW RESTART RESTART ALLOWSourcepub fn get_upgrade(self, requested: LockType) -> LockUpgrade
pub fn get_upgrade(self, requested: LockType) -> LockUpgrade
Returns the upgrade result when a locker holds this lock and requests another.
This implements the 5x5 upgrade matrix from the:
READ WRITE RANGE_R RANGE_W RANGE_I
READ EXISTING WRITE_PROMOTE RANGE_READ_IMMED RANGE_WRITE_PROMOTE ILLEGAL
WRITE EXISTING EXISTING RANGE_WRITE_IMMED RANGE_WRITE_IMMED ILLEGAL
RANGE_READ EXISTING RANGE_WRITE_PROM EXISTING RANGE_WRITE_PROMOTE ILLEGAL
RANGE_WRITE EXISTING EXISTING EXISTING EXISTING ILLEGAL
RANGE_INS ILLEGAL ILLEGAL ILLEGAL ILLEGAL EXISTINGTrait Implementations§
impl Copy for LockType
impl Eq for LockType
Source§impl Ord for LockType
impl Ord for LockType
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for LockType
impl PartialOrd for LockType
impl StructuralPartialEq for LockType
Auto Trait Implementations§
impl Freeze for LockType
impl RefUnwindSafe for LockType
impl Send for LockType
impl Sync for LockType
impl Unpin for LockType
impl UnsafeUnpin for LockType
impl UnwindSafe for LockType
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.