Skip to main content

BasicLocker

Struct BasicLocker 

Source
pub struct BasicLocker { /* private fields */ }
Expand description

A non-transactional locker.

Locks are released immediately when the cursor moves or closes. Does not support commit/abort semantics or write lock tracking for undo.

BasicLocker is used for non-transactional database operations where locks only need to be held for the duration of a single API call.

Implementations§

Source§

impl BasicLocker

Source

pub fn new(id: i64, lock_manager: Arc<LockManager>) -> Self

Creates a new BasicLocker.

§Arguments
  • id - Unique locker ID (often a shared constant for all BasicLockers)
  • lock_manager - Shared lock manager
Source

pub fn with_timeout( id: i64, lock_manager: Arc<LockManager>, timeout_ms: u64, ) -> Self

Creates a BasicLocker with a specified timeout.

Source

pub fn with_no_wait(id: i64, lock_manager: Arc<LockManager>) -> Self

Creates a BasicLocker with non-blocking mode.

Source

pub fn register_cursor(&mut self, is_internal_db_cursor: bool)

Called by cursor open/init to configure whether locking is required.

Sets lockingRequired = !cursor.isInternalDbCursor(). Internal-DB cursors (e.g. the utilization DB cursor) bypass the lock table entirely.

Source

pub fn release_all_locks(&mut self) -> Result<(), TxnError>

Release all locks held by this locker.

Called when the locker is closed or when a cursor moves.

Source

pub fn set_lock_timeout(&mut self, timeout_ms: u64)

Sets the lock timeout.

Source

pub fn set_default_no_wait(&mut self, no_wait: bool)

Sets the default no-wait mode.

Trait Implementations§

Source§

impl Drop for BasicLocker

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl Locker for BasicLocker

Source§

fn id(&self) -> i64

Returns the unique ID of this locker. Read more
Source§

fn lock( &mut self, lsn: u64, lock_type: LockType, non_blocking: bool, ) -> Result<LockResult, TxnError>

Acquires a lock on the given LSN. Read more
Source§

fn release_lock(&mut self, lsn: u64) -> Result<(), TxnError>

Releases a lock on the given LSN. Read more
Source§

fn owns_write_lock(&self, lsn: u64) -> bool

Returns true if this locker owns a write lock on the given LSN.
Source§

fn is_transactional(&self) -> bool

Returns true if this locker is transactional (supports commit/abort). Read more
Source§

fn lock_timeout_ms(&self) -> u64

Returns the timeout for lock attempts in milliseconds. Read more
Source§

fn default_no_wait(&self) -> bool

Returns true if this locker uses non-blocking lock requests by default. Read more
Source§

fn locking_required(&self) -> bool

Returns true if locking is required for this locker’s current context. Read more
Source§

fn operation_end(&mut self) -> Result<(), TxnError>

Called at the end of a non-transactional operation to release locks. Read more
Source§

fn release_non_txn_locks(&mut self) -> Result<(), TxnError>

Releases all non-transactional locks held by this locker. Read more
Source§

fn non_txn_operation_end(&mut self) -> Result<(), TxnError>

Called after a non-transactional operation ends, releasing locks and closing the locker. Read more
Source§

fn close(&mut self)

Marks this locker as closed. After close, no operations should occur. Read more
Source§

fn is_open(&self) -> bool

Returns true if this locker is still open.
Source§

fn owns_any_lock(&self, lsn: u64) -> bool

Returns true if this locker owns ANY lock (read or write) on the given LSN. Read more
Source§

fn retains_locks_on_commit(&self) -> bool

Returns true if locks should be retained on commit (serializable isolation). Read more
Source§

fn is_preemptable(&self) -> bool

Returns true if this locker’s locks can be preempted/stolen. Read more
Source§

fn is_importunate(&self) -> bool

Returns true if this locker can steal other lockers’ locks. Read more
Source§

fn is_read_uncommitted_default(&self) -> bool

Returns true if this locker allows read-uncommitted by default. Read more
Source§

fn shares_locks_with(&self, other_id: i64) -> bool

Returns true if this locker shares locks with the locker identified by other_id. Read more
Source§

fn txn_timeout_ms(&self) -> u64

Returns the transaction-level timeout in milliseconds. Read more
Source§

fn is_timed_out(&self) -> bool

Returns true if the transaction-level timeout has expired. Read more
Source§

fn lock_after_lsn_change( &mut self, _old_lsn: u64, _new_lsn: u64, ) -> Result<(), TxnError>

Called by the lock manager when an LN is moved to a new LSN without first acquiring a write lock (e.g. during eviction or cleaning). Read more
Source§

fn is_serializable_isolation(&self) -> bool

Returns true if this locker uses serializable (repeatable-read) isolation. Read more
Source§

fn is_read_committed_isolation(&self) -> bool

Returns true if this locker uses read-committed isolation. Read more
Source§

fn get_txn_locker_id(&self) -> Option<i64>

Returns the transaction ID if this locker is or owns a Txn, else None. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.