mco_trans_set_cleanup_period

Control how often the MVCC Transaction Manager removes unused versions.

Prototype

 
    int mco_trans_set_cleanup_period( /*IN*/ mco_db_h db,
                        /*IN*/ int cleanup_period, 
                        /*IN*/ mco_bool per_connection_cleanup);
 

Arguments

db The database handle that was established by mco_db_connect()

cleanup_period

The number of commits to process before removing unused versions

per_connection_cleanup

A boolean value: MCO_YES or MCO_NO

Description

This function controls how often (after what number of commits) the MVCC Transaction Manager removes unused versions for this connection (if per_connection_cleanup is set to MCO_YES). The per connection clean-up can be suppressed by setting up the cleanup_period to zero. This is important for the applications that create many short write transactions and long READ_ONLY transactions. It makes sense to do the cleanup only in the READ_ONLY transactions (as the READ_WRITE transactions won’t be able to cleanup anything anyway - they would have to wait until a potentially long READ_ONLY transaction 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_cleanup is set to MCO_NO, any left over 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.

Return Codes

Integer Previous value of cleanup_period

Example

 
    Application snippet:
        
     
    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 );
        }
        ...
    }
     
 

Files

Header file:
mco.h
Source file:
mursiw.c
Library:
libmcotexcl.a
Header file:
mco.h
Source file:
mursiw.c
Library:
libmcotmursiw.a
Header file:
mco.h
Source file:
mvcc.c
Library:
libmcotmvcc.a
Header file:
mco.h
Source file:
mursiw.c
Library:
libmcotread.a