Library Version 11.2.5.3

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

## DbEnv::txn_applied()

    #include <db_cxx.h>

    int
    DB_ENV->txn_applied(DB_ENV *env, DB_TXN_TOKEN *token,
                        db_timeout_t timeout, u_int32_t flags);

The `DbEnv::txn_applied()` method checks to see if a specified transaction has been replicated from the master of a replication group. It may be called by applications using either the Base API or the Replication Manager.

If the transaction has not yet arrived, this method will block for the amount of time specified on the `timeout` parameter while it waits for the result to be determined. For more information, please refer to the Read your writes consistency section in the Berkeley DB Programmer's Reference Guide.

The `DbEnv::txn_applied()` method may not be called before the DbEnv::open() method.

The `DbEnv::txn_applied()` method returns a non-zero error on failure and 0 to indicate that the specified transaction has been applied at the local site. It may also return one of the following non-zero return codes:

- `DB_TIMEOUT`

  Returned if the specified transaction has not yet arrived at the calling site, but can be expected to arrive soon. If a non-zero timeout parameter is given, the this method always waits for the specified amount of time before returning `DB_TIMEOUT`.

- `DB_NOTFOUND`

  Returned if the transaction is expected to never arrive. This occurs if the transaction has not been applied at the local site because the transaction has been rolled back due to a master takeover.

### Parameters

#### flags

The flags parameter is currently unused, and must be set to 0.

#### token

A pointer to a buffer containing a copy of a commit token previously generated at the replication group's master environment. Commit tokens are created using the DbTxn::set_commit_token() method.

#### timeout

Specifies the maximum time to wait for the transaction to arrive by replication, expressed in microseconds. To check the status of the transaction without waiting, provide a timeout value of 0.

### Errors

The `DbEnv::txn_applied()` 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:

#### DB_KEYEMPTY

The specified token was generated by a transaction that did not modify the database environment (for example, a read-only transaction).

#### DbDeadlockException or DB_LOCK_DEADLOCK

While waiting for the result to be determined, the API became locked out due to replication role change and/or master/client synchronization. The application should abort in-flight transactions, pause briefly, and then retry.

DbDeadlockException is thrown if your Berkeley DB API is configured to throw exceptions. Otherwise, `DB_LOCK_DEADLOCK` is returned.

#### EINVAL

If the specified token was generated from a non-replicated database environment.

### Class

DbEnv

### See Also

Transaction Subsystem and Related Methods, Replication and Related Methods

Prev | Up | Next
DbEnv::repmgr_stat_print() | Home | DbTxn::set_commit_token()