Persistent Database Recovery from Failed Processes in C

Persistent database recovery can be necessary in the case of a system failure. The eXtremeDB runtime uses the transaction log file to perform recovery automatically when mco_db_open_dev() is called.

Note that, for automatic recovery, it is important that either the RedoLog (the default) or UndoLog log file type was active in the process that was updating the database at the moment of the system failure. In other words, if the log file type was NoLog in the crashed process, recovery will not be possible. 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_type are : NO_LOG, REDO_LOG or UNDO_LOG. (Please refer to the Setting the Log File Type page for explanation of the log file options.)

No additional API or action by the application is necessary for automatic recovery. (Please see SDK sample 19_recovery_diskrecovery for an example.)