Library Version 18.1.40

DbEnv::rep_set_timeout()
Prev | Chapter 11. Replication Methods | Next

## DbEnv::rep_set_timeout()

    #include <db_cxx.h>

    int
    DbEnv::rep_set_timeout(int which, u_int32_t timeout);

The `DbEnv::rep_set_timeout()` method specifies a variety of replication timeout values.

The database environment's replication subsystem 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 "rep_set_timeout", one or more whitespace characters, and the which parameter specified as a string and the timeout. For example, "rep_set_timeout DB_REP_CONNECTION_RETRY 15000000" specifies the connection retry timeout for 15 seconds. Because the DB_CONFIG file is read when the database environment is opened, it will silently overrule configuration done before that time.

The `DbEnv::rep_set_timeout()` method configures a database environment, not only operations performed using the specified DbEnv handle.

The `DbEnv::rep_set_timeout()` method may not be called to set the master lease timeout after the DbEnv::repmgr_start() method or the DbEnv::rep_start() method is called. For all other timeouts, the `DbEnv::rep_set_timeout()` method may be called at any time during the life of the application.

The `DbEnv::rep_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

#### which

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

- `DB_REP_ACK_TIMEOUT`

  Configure the amount of time the Replication Manager's transport function waits to collect enough acknowledgments from replication group clients, before giving up and returning a failure indication. The default wait time is 1 second. Automatic takeover of a subordinate process is most reliable when this value is the same on all sites in the replication group.

- `DB_REP_CHECKPOINT_DELAY`

  Configure the amount of time a master site will delay between completing a checkpoint and writing a checkpoint record into the log. This delay allows clients to complete their own checkpoints before the master requires completion of them. The default is 30 seconds. If all databases in the environment, and the environment's transaction log, are configured to reside in memory (never preserved to disk), then, although checkpoints are still necessary, the delay is not useful and should be set to 0.

- `DB_REP_CONNECTION_RETRY`

  Configure the amount of time the Replication Manager will wait before trying to re-establish a connection to another site after a communication failure. The default wait time is 30 seconds.

- `DB_REP_ELECTION_TIMEOUT`

  The timeout period for an election. The default timeout is 2 seconds.

- `DB_REP_ELECTION_RETRY`

  Configure the amount of time the Replication Manager will wait before retrying a failed election. The default wait time is 10 seconds. In preferred master mode, a shorter wait time is recommended to facilitate automatic takeovers, so the default wait time is reduced to 1 second.

- `DB_REP_FULL_ELECTION_TIMEOUT`

  An optional configuration timeout period to wait for full election participation the first time the replication group finds a master. By default this option is turned off and normal election timeouts are used. (See the Elections section in the Berkeley DB Programmer's Reference Guide for more information.)

- `DB_REP_HEARTBEAT_MONITOR`

  The amount of time the Replication Manager, running at a client site, waits for some message activity on the connection from the master (heartbeats or other messages) before concluding that the connection has been lost. This timeout should be of longer duration than the `DB_REP_HEARTBEAT_SEND` timeout to ensure that heartbeats are not missed. When 0 (the default), no monitoring is performed. In preferred master mode the default is 2 seconds and heartbeat monitoring cannot be turned off because heartbeats are required for automatic takeovers.

- `DB_REP_HEARTBEAT_SEND`

  The frequency at which the Replication Manager, running at a master site, broadcasts a heartbeat message in an otherwise idle system. Heartbeat messages are used at client sites to monitor the connection to the master and to help request missing master changes in the absence of master activity. When 0 (the default), no heartbeat messages will be sent. In preferred master mode the default is 0.75 second and heartbeats cannot be turned off because they are required for automatic takeovers.

- `DB_REP_LEASE_TIMEOUT`

  Configure the amount of time a client grants its master lease to a master. When using master leases all sites in a replication group must use the same lease timeout value. There is no default value. If leases are desired, this method must be called prior to calling the DbEnv::repmgr_start() method or the DbEnv::rep_start() method. See also DbEnv::rep_set_clockskew() method, DbEnv::rep_set_config() method and Master leases.

- `DB_REP_WRITE_FORWARD_TIMEOUT`

  Configure the amount of time a Replication Manager client waits for a response from a forwarded write operation before returning a failure indication. The default value is 5 seconds.

  For more information on write forwarding, see the Berkeley DB Programmer's Reference Guide.

#### 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.

### Errors

The `DbEnv::rep_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

If setting the lease timeout and replication has already been started; if turning off a heartbeat timeout in Replication Manager preferred master mode; if setting a Replication Manager timeout for a Base API application; or if an invalid flag value or parameter was specified.

### Class

DbEnv

### See Also

Replication and Related Methods

Prev | Up | Next
DbEnv::rep_set_request() | Home | DbEnv::rep_set_transport()