Explicitly remove the unused versions made by the MVCC transaction manager.
MCO_RET mco_disk_database_vacuum( /*IN*/ mco_db_h db );
db | The database handle that was established by mco_db_connect() |
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 theMCO_DB_MODE_MVCC_AUTO_VACUUM
mode mask in the mco_db_params_t when callingmco_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 becausemco_disk_database_vacuum()
iterates through all allocated pages (pages marked as allocated in the bitmap) and callingClassname_set_allocation_block_size()
actually causes the runtime to allocate the whole block only part of which is used and properly initialized.
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 |
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 ); ... } }