Berkeley DB: lock_detect
Description: Berkeley DB: An embedded database programmatic toolkit.
Keywords: embedded,database,programmatic,toolkit,b+tree,btr ee,hash,hashing,transaction,transactions,locking,logging,access method,access me thods,java,C,C++

# lock_detect

`

###

    #include <db.h>

    int
    lock_detect(DB_LOCKTAB *lt,
        u_int32_t flags, u_int32_t atype);

# Description

The lock_detect function runs one iteration of the deadlock detector. The deadlock detector traverses the lock table, and for each deadlock it finds, marks one of the participating transactions for abort.

The flags value is specified by logically OR'ing together one or more of the following values:

DB_LOCK_CONFLICT
  Only run the deadlock detector if a lock conflict has occurred since the last time that the deadlock detector was run.

The atype parameter specifies which transaction to abort in the case of deadlock. It must be set to one of values described for the lk_detect field of the DB_ENV structure.

The lock_detect function is the underlying function used by the db_deadlock utility. See the db_deadlock utility source code for an example of using lock_detect in a POSIX 1003.1 environment.

The lock_detect function returns the value of errno on failure, and 0 on success.

# Errors

If a fatal error occurs in Berkeley DB, the lock_detect function may fail and return DB_RUNRECOVERY, at which point all subsequent database calls will also return DB_RUNRECOVERY.

The lock_detect function may fail and return errno for any of the errors specified for the following Berkeley DB and C library functions: abort(3), fcntl(3), fflush(3), fprintf(3), free(3), fsync(3), getpid(3), lseek(3), malloc(3), memcpy(3), memset(3), mmap(3), munmap(3), shmat(3), shmdt(3), sprintf(3), strerror(3), vfprintf(3), vsnprintf(3), and write(3).

# See Also

lock_close, lock_detect, lock_get, lock_id, lock_open, lock_put, lock_stat, lock_unlink and lock_vec.`