As explained in the persistent database recovery page the eXtremeDB runtime uses the transaction log file to perform recovery automatically in the case of a prior application crash. The Persistent Database I/O page explains the different log types and how to choose the appropriate type for different application profiles. The manner in which transactions are written to the log is determined by the transaction commit policy. The following sections explain how to set the log type and commit policy in C applications.
Log type
The log type is specified in the
mco_db_params_t.db_log_type. For example:mco_db_params_t db_params; ... mco_db_params_init ( &db_params ); /* initialize the params with default values */ // Set log file type db_params.db_log_type = UNDO_LOG;Note that the valid options for
db_log_typeare :NO_LOG, REDO_LOGorUNDO_LOG.Commit Policy
As explained in the Persistent Database I/O page, eXtremeDB offers four distinct commit policy options for log types
REDO_LOGandUNDO_LOG. The application can call functionmco_disk_transaction_policy()at runtime with one of the following values:MCO_COMMIT_SYNC_FLUSH, MCO_COMMIT_BUFFERED, MCO_COMMIT_DELAYED,orMCO_COMMIT_NO_SYNC. The commit policy can also be set inmco_log_params_t.default_commit_policyof themco_db_params_t.log_paramsparameter passed tomco_db_open_dev().The
MCO_COMMIT_NO_SYNCpolicy causes all transactions to be held in the cache until the application explicitly forces the cache to be flushed to the media with themco_disk_flush()function.There are additional parameters to consider for the
REDO_LOGlog type. For theMCO_COMMIT_DELAYEDpolicy, the database disk manager keeps the transaction in memory until a specified percentage of the log file size is reached. The threshold valuesmco_log_params_t.redo_log_limit,mco_log_params_t.delayed_commit_thresholdandmco_log_params_t.max_delayed_transactionscan be set by applications at runtime by calling functionmco_disk_set_log_params(). Or these values can be specified in themco_db_params_t.log_paramsparameter passed tomco_db_open_dev(). By default, the threshold is set to be a half of the available page pool size.