Control how often the MVCC Transaction Manager removes unused versions.
int mco_trans_set_cleanup_period( /*IN*/ mco_db_h db,
/*IN*/ int cleanup_period,
/*IN*/ mco_bool per_connection_cleanup);
db
mco_db_connect().cleanup_period
per_connection_cleanup
MCO_YES or MCO_NO.This function controls how often (after what number of commits) the MVCC Transaction Manager removes unused versions for this connection (if
per_connection_cleanupis set toMCO_YES). The per-connection clean-up can be suppressed by setting thecleanup_periodto zero. This is important for the applications that create many short write transactions and longREAD_ONLYtransactions. It makes sense to do the cleanup only in theREAD_ONLYtransactions (as theREAD_WRITEtransactions won’t be able to clean up anything anyway—they would have to wait until a potentially longREAD_ONLYtransaction is committed). It is important to emphasize that if the unused versions are not removed, a huge number of duplicate indexes could lead to performance degradation.When the task is disconnected from the database, or if
per_connection_cleanupis set toMCO_NO, any leftover unused versions created by the connections are placed into a “common pool” (common to all connections), which is processed by all connections. Thus, if task A does not normally touch the table T, it could still cause the removal of a version of T from the indexes, and therefore would need to apply locks to the runtime while accessing the index. We recommend implementing a task (connection) that works with the global pool and would be the last one to disconnect from the database. The default settings are to use the global pool. Using the local (per-connection) pool makes sense for applications that access a separate set of tables (classes) from different tasks (connections) and thus don’t create any locking conflicts.
int
cleanup_period.
const char * dbname = "SimpleDb";
int main(int argc, char* argv[])
{
mco_db_h db;
MCO_RET rc;
mco_device_t dev;
mco_db_params_t db_params;
mco_trans_h t;
int period = 1000;
...
rc = mco_db_open_dev( dbname, simple_get_dictionary(), &dev, 1, &db_params );
if ( MCO_S_OK != rc )
{
rc = mco_db_connect( dbname, &db );
...
period = mco_trans_set_cleanup_period( db, period, MCO_NO );
printf("\nThe previous Cleanup Period was %d.", period );
}
...
}