NuDB Logo

PrevUpHomeNext

recover

Perform recovery on a database.

template<
    class Hasher,
    class File = native_file,
    class... Args>
void
recover(
    path_type const& dat_path,
    path_type const& key_path,
    path_type const& log_path,
    error_code& ec,
    Args&&... args);

This implements the recovery algorithm by rolling back any partially committed data. If no log file is present, the function does nothing.

During the commit phase of a NuDB database, a log file is generated with information that may be used to roll back the results of a partial commit. This function checks for the presence of a log file. If present, the log file is replayed on the key and data files belonging to the database, restoring the database to its state before the partial commit. When recover is successful, it erases the log file.

It is normally not necessary to call this function directly, it is called automatically when a database is opened in a call to basic_store::open. Callers may use this function to implement auxiliary tools for manipulating the database.

Template Parameters

Hasher

The hash function to use. This type must meet the requirements of Hasher. The hash function must be the same as that used to create the database, or else an error is returned.

File

The type of file to use. Use the default of native_file unless customizing the file behavior.

Parameters

dat_path

The path to the data file.

key_path

The path to the key file.

log_path

The path to the log file.

args

Optional parameters passed to File constructors.

ec

Set to the error, if any occurred.

Requirements

Header: nudb/recover.hpp


PrevUpHomeNext