DbEnv::set_timeout()

#include <db_cxx.h>

int
DbEnv::set_timeout(db_timeout_t timeout, u_int32_t flags); 

The DbEnv::set_timeout() method sets timeout values for locks or transactions in the database environment, and the wait time for a process to exit the environment when DB_REGISTER recovery is needed.

DB_SET_LOCK_TIMEOUT and DB_SET_TXN_TIMEOUT timeouts are checked whenever a thread of control blocks on a lock or when deadlock detection is performed. In the case of DB_SET_LOCK_TIMEOUT, the lock is one requested explicitly through the Lock subsystem interfaces. In the case of DB_SET_TXN_TIMEOUT, the lock is one requested on behalf of a transaction. In either case, it may be a lock requested by the database access methods underlying the application. These timeouts are only checked when the lock request first blocks or when deadlock detection is performed, the accuracy of the timeout depends on how often deadlock detection is performed.

Lock and transaction timeout values specified for the database environment may be overridden on a per-lock or per-transaction basis. See DbEnv::lock_vec() and DbTxn::set_timeout() for more information.

The DbEnv::set_timeout() method may not be used in a database environment without a locking subsystem.

The DbEnv::set_timeout() method may be called at any time during the life of the application.

The DbEnv::set_timeout() method either returns a non-zero error value or throws an exception that encapsulates a non-zero error value on failure, and returns 0 on success.

Parameters

timeout

The timeout parameter is the timeout value. It must be specified as an unsigned 32-bit number of microseconds, limiting the maximum timeout to roughly 71 minutes.

flags

The flags parameter must be set to one of the following values:

  • DB_SET_LOCK_TIMEOUT

    Set the timeout value for locks in this database environment.

    The database environment's lock timeout value may also be configured using the environment's DB_CONFIG file. The syntax of the entry in that file is a single line with the string "set_lock_timeout", one or more whitespace characters, and the lock timeout value. Because the DB_CONFIG file is read when the database environment is opened, it will silently overrule configuration done before that time.

    This flag configures a database environment, not only operations performed using the specified DbEnv handle.

  • DB_SET_MUTEX_FAILCHK_TIMEOUT

    If failchk broadcasting has been configured, then set the timeout value on how long a thread will wait for a mutex lock before checking whether DbEnv::failchk() has marked the mutex as failed. The default is to check once every second.

    This wait timeout value may also be configured using the environment's DB_CONFIG file. The syntax of the entry in that file is a single line with the string "set_mutex_failchk_timeout", one or more whitespace characters, and the wait timeout value. Because the DB_CONFIG file is read when the database environment is opened, it will silently overrule configuration done before that time.

    This flag configures operations performed using the specified DbEnv handle.

  • DB_SET_REG_TIMEOUT

    Set the timeout value on how long to wait for processes to exit the environment before recovery is started when the DbEnv::open() method was called with the DB_REGISTER flag and recovery must be performed.

    This wait timeout value may also be configured using the environment's DB_CONFIG file. The syntax of the entry in that file is a single line with the string "set_reg_timeout", one or more whitespace characters, and the wait timeout value. Because the DB_CONFIG file is read when the database environment is opened, it will silently overrule configuration done before that time.

    This flag configures operations performed using the specified DbEnv handle.

  • DB_SET_TXN_TIMEOUT

    Set the timeout value for transactions in this database environment.

    The database environment's transaction timeout value may also be configured using the environment's DB_CONFIG file. The syntax of the entry in that file is a single line with the string "set_txn_timeout", one or more whitespace characters, and the transaction timeout value. Because the DB_CONFIG file is read when the database environment is opened, it will silently overrule configuration done before that time.

    This flag configures a database environment, not only operations performed using the specified DbEnv handle.

Errors

The DbEnv::set_timeout() method may fail and throw a DbException exception, encapsulating one of the following non-zero errors, or return one of the following non-zero errors:

EINVAL

DB_SET_MUTEX_FAILCHK_TIMEOUT was specified even though Berkeley DB was not configured with --enable-failchk_broadcast; an invalid flag value or parameter was specified;

Class

DbEnv

See Also

Database Environments and Related Methods