mco_disk_database_vacuum

Explicitly remove the unused versions made by the MVCC transaction manager.

Prototype

 
    MCO_RET	mco_disk_database_vacuum(	/*IN*/ mco_db_h db );
 

Arguments

db The database handle that was established by mco_db_connect()

Description

When the MVCC transaction manager is used, in the case of a system crash, a persistent database can contain undeleted old versions and working copies. Their presence will not break the consistency of the database and doesn't prevent the normal working of an application, but does unnecessarily consume space. Detecting these stale object versions requires a complete scan of the database. This is why the automatic recovery process doesn't perform this function automatically. The removal of the unused versions can be performed explicitly by calling the mco_disk_database_vacuum(). Alternatively, the application can enable the repair process by setting the MCO_DB_MODE_MVCC_AUTO_VACUUM mode mask in the mco_db_params_t when calling mco_db_open_dev ().

Please note that mco_disk_database_vacuum() requires exclusive access to the database, so no operations can be performed on the database until the vacuum operation is complete and the function has returned control back to the application.

Note that this function is not compatible with the Classname_set_allocation_block_size() API because mco_disk_database_vacuum() iterates through all allocated pages (pages marked as allocated in the bitmap) and calling Classname_set_allocation_block_size() actually causes the runtime to allocate the whole block only part of which is used and properly initialized.

Return Codes

MCO_S_OK Operation completed successfully
MCO_E_DISK_PAGE_ACCESS

Error accessing a page from disk

MCO_E_DISK_OPERATION_NOT_ALLOWED Disk manager filesize not sufficient

Example

 
    Application snippet:
        
     
    const char * dbname = "SimpleDb";
     
    int main(int argc, char* argv[])
    {
        mco_db_h db;
        MCO_RET rc;
        mco_device_t       dev[4];
        mco_db_params_t    db_params;
                 
        ...
        rc = mco_db_open_dev( dbname, simple_get_dictionary(), dev, 4, &db_params );
             
        if ( MCO_S_OK != rc )
        {
            rc = mco_db_connect(  dbname, &db );
            ...
            rc = mco_disk_database_vacuum( db );
        
            ...
        }
    }
 

Files

Header file:
mco.h
Source file:
mcodisk.c
Library:
libmcovtdsk.a
Header file:
mco.h
Source file:
mcovtmem.c
Library:
libmcovtmem.a