public void lock_vec(int locker, int flags, DbLockRequest list,
int offset, int count)
The DbEnv.lock_vec method atomically obtains and releases one or more locks
from the lock table. The DbEnv.lock_vec method is intended to support
acquisition or trading of multiple locks under one lock table semaphore,
as is needed for lock coupling or in multigranularity locking for lock
The locker argument specified to DbEnv.lock_vec is an unsigned
32-bit integer quantity. It represents the entity requesting or releasing
The flags value must be set to 0 or
the following value:
- If a lock cannot be granted because the requested lock conflicts with
an existing lock,
throw a DbLockNotGrantedException immediately instead of waiting
for the lock to become available. In this case, the index of the request
that was not granted can be found by calling
The list array provided to DbEnv.lock_vec is a set of
DbLockRequest objects. Only count elements of list
starting at offset are considered by DbEnv.lock_vec.
A DbLockRequest object has at least the following fields.
For each field there is a corresponding get_ and set_ method
- int op;
- The operation to be performed, which must be set to one of the
- Get the lock defined by the values of the mode and obj
structure fields, for the specified locker. Upon return from
DbEnv.lock_vec, if the lock field is non-null, a reference
to the acquired lock is stored there. (This reference is invalidated
by any call to DbEnv.lock_vec or DbEnv.lock_put that releases the
- Identical to Db.DB_LOCK_GET except that the value in the timeout
structure field overrides any previously specified timeout value for
this lock. A value of 0 turns off any previously specified timeout.
- The lock to which the lock structure field refers is released.
The locker argument, and mode and obj fields
- All locks held by the specified locker are released. The
lock, mode, and obj structure fields are
ignored. Locks acquired in operations performed by the current call to
DbEnv.lock_vec which appear before the Db.DB_LOCK_PUT_ALL
operation are released; those acquired in operations appearing after
the Db.DB_LOCK_PUT_ALL operation are not released.
- All locks held on the object obj are released. The
locker argument and the lock and mode structure
fields are ignored. Locks acquired in operations performed by the
current call to DbEnv.lock_vec that appear before the
Db.DB_LOCK_PUT_OBJ operation are released; those acquired in
operations appearing after the Db.DB_LOCK_PUT_OBJ operation are
- Cause the specified locker to timeout immediately. If the
database environment has not configured automatic deadlock detection,
the transaction will timeout the next time deadlock detection is
performed. As transactions acquire locks on behalf of a single locker
ID, timing out the locker ID associated with a transaction will time
out the transaction itself.
- DbLock lock;
- A lock reference.
- int mode;
- The lock mode, used as an index into the environment's lock conflict matrix.
When using the default lock conflict matrix, mode must be set to one
of the following values:
- read (shared)
- write (exclusive)
- intention to write (shared)
- intention to read (shared)
- intention to read and write (shared)
See DbEnv.set_lk_conflicts and Standard Lock Modes for more information on the lock conflict matrix.
- Dbt obj;
- An untyped byte string that specifies the object to be locked or
released. Applications using the locking subsystem directly while also
doing locking via the Berkeley DB access methods must take care not to
inadvertently lock objects that happen to be equal to the unique file
IDs used to lock files. See Access
method locking conventions for more information.
- int timeout;
- The lock timeout value.
If any of the requested locks cannot be acquired, or any of the locks to
be released cannot be released, the operations before the failing
operation are guaranteed to have completed successfully, and
DbEnv.lock_vec throws an exception
Otherwise, the DbEnv.lock_vec method throws an exception that encapsulates a non-zero error value on
The DbEnv.lock_vec method may fail and throw an exception encapsulating a non-zero error for the following conditions:
- An invalid flag value or parameter was specified.
- The maximum number of locks has been reached.
If the operation was selected to resolve a deadlock, the
DbEnv.lock_vec method will fail and
throw a DbDeadlockException exception.
The DbEnv.lock_vec method may fail and throw an exception for errors specified for other Berkeley DB and C library or system methods.
If a catastrophic error has occurred, the DbEnv.lock_vec method may fail and
throw a DbRunRecoveryException,
in which case all subsequent Berkeley DB calls will fail in the same way.
Locking Subsystem and Related Methods
Copyright Sleepycat Software