|
As the Tideway Foundation data store runs, many database entries are created and deleted. As this takes place, the database structure can become fragmented, meaning that there are 'gaps' in the data. The database files therefore tend to grow over time, even if the amount of useful data remains constant. The solution to this situation is to periodically compact the data store. The compaction procedure defragments the databases, reclaiming the space wasted in the 'gaps'.
There are two different compaction tools available. The simplest and most common approach is to perform an online compaction. In some circumstances, it is useful to perform an offline copying compaction. Online compactionOnline compaction is triggered using the tw_ds_online_compact command line tool. The command line options for the tool are:
Running compactionSince it performs an online compaction, the tideway service must be running for the script to operate. Running tw_ds_online_compact with no options triggers compaction of the whole data store. It prints out each node / relationship kind as it goes. Since compaction touches all of the data in the databases, it is best if the data store is relatively quiet during the compaction process. By default, the tool therefore refuses to run if Discovery is running. Discovery should be stopped (either through the web user interface, or by using the tw_injectip script). Alternatively, you can force compaction to run regardless of the Discovery status by specifying the --force command line option. Compaction of a particular node or relationship kind cannot be stopped once it has started. If you interrupt the script with ctrl-c, it will wait until it has finished the node / relationship kind it is working on before exiting. Compacting individual node / relationship kindsRather than compacting the whole data store, you can compact individual node or relationship kinds by specifying them on the command line with --nodekind or --relkind respectively. The --list command line option outputs a list of all the node and relationship kinds stored in the data store. Copying compactionInstead of the usual online method, the data store can be compacted with an offline copying compaction that writes a new copy of the database files, performed by the tw_ds_compact script. This older compaction method is mainly supported for backwards compatibility, but it also has the ability to transform the data in two ways:
Preparing to Compact the Data StoreYou must prepare the database using the following procedure:
The databases are now ready for compaction. Compacting the Data StoreThe tw_ds_compact script compacts the data store by copying the data files. The command takes the form tw_ds_compact [options] <source directory> <destination directory> The command line options for the tw_ds_compact script are described in the Table below.
The script accesses the database files directly, outside the usual transactional environment. When you run the script, you must choose a destination directory for the new database files. Ideally you should store the new databases on a different disk, to minimise thrashing between reading the old files and writing the new ones. The new databases will generally be smaller than the originals, but you should ensure that there is at least the same amount of space as there is taken up by the current databases. In the following example, the new database files are stored on /mnt/bigdisk.
|
