Class RowLocking2
- All Implemented Interfaces:
LockingPolicy
- Direct Known Subclasses:
RowLocking1
,RowLocking2nohold
- See Also:
-
Field Summary
FieldsFields inherited from class org.apache.derby.impl.store.raw.xact.RowLocking3
lf
Fields inherited from interface org.apache.derby.iapi.store.raw.LockingPolicy
MODE_CONTAINER, MODE_NONE, MODE_RECORD
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
lockContainer
(Transaction t, ContainerHandle container, boolean waitForLock, boolean forUpdate) Obtain container level intent lock.boolean
lockRecordForRead
(Transaction t, ContainerHandle container_handle, RecordHandle record, boolean waitForLock, boolean forUpdate) Obtain lock on record being read.void
unlockContainer
(Transaction t, ContainerHandle container_handle) Unlock read locks.void
unlockRecordAfterRead
(Transaction t, ContainerHandle container_handle, RecordHandle record, boolean forUpdate, boolean row_qualified) Unlock a record after it has been locked for read.Methods inherited from class org.apache.derby.impl.store.raw.xact.RowLockingRR
getReadLockType, getUpdateLockType, getWriteLockType
Methods inherited from class org.apache.derby.impl.store.raw.xact.RowLocking3
getMode, lockRecordForWrite, zeroDurationLockRecordForWrite
-
Field Details
-
NO_LOCK
-
-
Constructor Details
-
RowLocking2
-
-
Method Details
-
lockContainer
public boolean lockContainer(Transaction t, ContainerHandle container, boolean waitForLock, boolean forUpdate) throws StandardException Obtain container level intent lock.This implementation of row locking is 2 level, ie. table and row locking. It will interact correctly with tables opened with ContainerLocking3 locking mode.
Updater's will get table level IX locks, and X row locks.
Reader's will get table level IS locks, and S row locks.
Read locks are put in a separate "group" from the transaction, so that when the container is closed it can release these read locks.
- Specified by:
lockContainer
in interfaceLockingPolicy
- Overrides:
lockContainer
in classRowLocking3
- Parameters:
t
- Transaction to associate lock with.container
- Container to lock.waitForLock
- Should lock request wait until granted?forUpdate
- Should container be locked for update, or read?- Returns:
- true if the lock was obtained, false if it wasn't. False should only be returned if the waitForLock policy was set to "false," and the lock was unavailable.
- Throws:
StandardException
- Standard exception policy.- See Also:
-
lockRecordForRead
public boolean lockRecordForRead(Transaction t, ContainerHandle container_handle, RecordHandle record, boolean waitForLock, boolean forUpdate) throws StandardException Obtain lock on record being read.Assumes that a table level IS has been acquired. Will acquire a Shared or Update lock on the row, depending on the "forUpdate" parameter.
Read lock will be placed on separate group from transaction.
- Specified by:
lockRecordForRead
in interfaceLockingPolicy
- Overrides:
lockRecordForRead
in classRowLocking3
- Parameters:
t
- The transaction to associate the lock with.container_handle
- Open Container used to get record. Will be used to row locks by the container they belong to.record
- The record to be locked.waitForLock
- Should lock request wait until granted?forUpdate
- Whether to open for read or write access.- Returns:
- true if the lock was granted, false if waitForLock was false and the lock could not be granted.
- Throws:
StandardException
- Standard exception policy.- See Also:
-
unlockRecordAfterRead
public void unlockRecordAfterRead(Transaction t, ContainerHandle container_handle, RecordHandle record, boolean forUpdate, boolean row_qualified) throws StandardException Description copied from class:RowLockingRR
Unlock a record after it has been locked for read.In repeatable read only unlock records which "did not qualify". For example in a query like "select * from foo where a = 1" on a table with no index it is only necessary to hold locks on rows where a=1, but in the process of finding those rows the system will get locks on other rows to verify they are committed before applying the qualifier. Those locks can be released under repeatable read isolation.
- Specified by:
unlockRecordAfterRead
in interfaceLockingPolicy
- Overrides:
unlockRecordAfterRead
in classRowLockingRR
- Throws:
StandardException
- Standard exception policy.- See Also:
-
unlockContainer
Unlock read locks.In Cursor stability release all read locks obtained. unlockContainer() will be called when the container is closed.
- Specified by:
unlockContainer
in interfaceLockingPolicy
- Overrides:
unlockContainer
in classNoLocking
- Parameters:
t
- The transaction to associate the lock with.container_handle
- Container to unlock.- See Also:
-