Dump and Load of the UMCA Disk Block Cache Manager Contents

The QHB instance can run for quite a long time. While running, it accumulates data about loaded disk blocks. If for some reason you need to stop it, this data will be lost. In this case, after launching the new instance will have to collect this data anew.

The UMCA (Universal Memory Cache Analyzer) module allows you to save the disk block cache manager contents in file system, and then load it back, thereby restoring the previous state. Due to this, no time is wasted on warming up the instance. (See Section TARQ Disk Block Cache Manager for a detailed description of the disk block cache manager.)

WARNING!
The UMCA functions work only if the use_qhb_cache parameter in the qhb.conf configuration file is set to true, otherwise calls to the functions will fail.



Creating a Dump

The built-in SQL function qhb_dump_disk_cache is used to create dumps. It copies the disk block cache manager contents and then saves it to a file. The number of saved blocks is returned as a result. When calling it, you must specify the dump type (character case does not matter). Correlative table of all dump types and affected page lists is presented below.

Dump TypeAffected Lists
FULLB1, B2, L1, L2
HOTL2
COLDL1
SHADOWB1, B2

Below is an example of calling qhb_dump_disk_cache, which results in a complete dump of the disk block cache manager contents. If there are no errors, the function was successful.

SELECT qhb_dump_disk_cache('FULL');

All dumps are saved in the qhb-disk-cache-dump subdirectory of the database directory. The file has a name consisting of the dump type (see table above) and the current UTC time.


Saving a Dump to a File with an Arbitrary Name

The qhb_dump_disk_cache function has a form with a second parameter that allows you to pass the file name under which the created dump will be saved. Below is an example of calling qhb_dump_disk_cache, which will result in creation a hot block dump named test.dump.

SELECT qhb_dump_disk_cache('HOT','old.dump');


Loading a Dump

To load from dumps, the built-in SQL function qhb_load_disk_cache is used. It loads data from a previously created dump. The result is the number of loaded blocks. When calling, you must specify the dump's name or absolute path. Below is an example of calling qhb_load_disk_cache, which will load the blocks. If there are no errors, then the function was executed successfully.

SELECT qhb_load_disk_cache('2020-12-03_12:50:21.dump');

In the example above, the dump name is specified, so the function will look for it in the standard subdirectory for disk block cache manager dump storage. You can also specify the full path to the dump, as it is done in the example below.

SELECT qhb_load_disk_cache('/opt/qhb-data/qhb-disk-cache-dumps/2020-12-03_12:50:21.dump');

Loading the Latest Dump

The qhb_load_disk_cache function has a form without parameters; in this case, the function will look for the last modified file available for reading. Below is an example of calling qhb_load_disk_cache without parameters.

SELECT qhb_load_disk_cache();

If there are multiple dumps in a directory, the touch command can be used to update the dump modification time, so it will be considered the latest one.

touch new-last.dump


Viewing Dump Files

The QHB distribution provides the qhb_disk_cache_dump_viewer utility, which allows you to view the contents of disk block cache manager dumps. Below is an example of using this utility.

qhb_disk_cache_dump_viewer 2020-12-03_15:34:53.dump

Sorting the Output

The qhb_disk_cache_dump_viewer utility has an output sorting option --sort-by (abbreviated as -s). By default, sorting by block number is enabled. Using the values ​​described in the table below, you can specify which column to sort the output by.

--sort-by Parameter ValueDescription
ForkNumsorts the output by fork_num column
BlockNumsorts the output by block_num column
SpcNodesorts the output by spc_node column
DbNodesorts the output by db_node column
RelNodesorts the output by rel_node column

Below is an example of the qhb_disk_cache_dump_viewer output.

GEN      ID: [ fork_num | block_num | spc_node | db_node | rel_node ]
L1        1: [        0 |         0 |     1663 |   12674 |     2615 ]
L1        2: [        0 |         5 |     1663 |   12674 |     2617 ]
L1        3: [        0 |         1 |     1663 |   12674 |     2654 ]
L1      129: [        2 |         0 |     1663 |   12674 |     3456 ]
L1      130: [        0 |        42 |     1663 |   12674 |     2838 ]
L1      257: [        0 |         1 |     1663 |   12674 |     1259 ]
L1      258: [        0 |         2 |     1663 |   12674 |     2610 ]
L1      259: [        0 |         3 |     1663 |   12674 |     2696 ]

Getting the Dump Size in Blocks

The qhb_disk_cache_dump_viewer utility has a parameter --size (abbreviated as -S) for displaying the dump size in blocks. This parameter is incompatible with --sort-by.

Below is an example of the output of qhb_disk_cache_dump_viewer with the --size parameter.

B1: 0
B2: 0
L1: 159
L2: 0
Total: 159