Sometimes when a process gets killed or crashes unexpectedly a database shared memory segment may become locked and inaccessible by other processes (either processes that are already running or newly launched processes) yet there may be a need to rescue valuable data remaining in this in-memory database.
The
shdumputility can be used to create an emergency backup for such a segment.
shdumpshould be used as "a last resort" only, when all other options are exhausted and right before the final cleanup/restart of "frozen" application(s). This tool should never be combined with regular database operations. (Please refer to Backup and restore if you need to backup data routinely.)- It is not guaranteed that data will be saved completely or that all transactions will be completed.
- On the Windows platform at least one process holding the affected shared memory segment should remain alive (even if stuck/non-operational).
Rescue procedure overview
- Dump the database segment into a file with shdump.
- Create a temporary database and load the file into it, then make a regular backup from this temporary database. This step can be performed on a different machine, so that the affected shared memory segment may be left in memory.
- Restore the backup into a regular eXtremeDB instance, check the data and use it normally.
Usage
shdump [-dr] [-s size] [-c max_connections] [-a address] [-p page_size] [ -n dbname] segment_name);
sizeis the size of the memory segment in bytes. Suffix-modifiers 'k', 'm', 'g' meaning kilobytes, megabytes and gigabytes can be appended.addressis an address to which to restore segment (in HEX format:0xHHHHH)page_sizeis database page size. Default value is 512 bytes. Used only when restoring databasedbnameis the name of resulting database. Used only for restoreExample
Dump step
shdump -s 128M segmentNameThis will create file
segmentName.dmpwith size of 128Mb and save the contents of the shared memory segment named "segmentName".Backup step
shdump -a 0x20000000 -r -p 4096 -n kbss_stds -s 128m -c 256 segmentNameThis command will load the segment dump file "
segmentName.dmp" into memory, open an IM database using that segment and create backupdb.bak file with the regular eXtremeDB backup.This file is suitable for loading by xsql with the
-imageoption or with the mco_db_load() eXtremeDB C API call.Optional XSQL check step
Assume that database parameters are described in the corresponding
xsql.cfgconfiguration file:xsql -c xsql.cfg -image backupdb.bak