Shared Memory Segment Emergency Recovery

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 shdump utility can be used to create an emergency backup for such a segment.

Rescue procedure overview

  1. Dump the database segment into a file with shdump.
  2. 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.
  3. 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);
     

Example

  1. Dump step

     
        shdump  -s 128M segmentName
    						 

    This will create file segmentName.dmp with size of 128Mb and save the contents of the shared memory segment named "segmentName".

  2. Backup step

     
        shdump -a 0x20000000 -r -p 4096 -n kbss_stds -s 128m -c 256 segmentName
    						 

    This 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 -image option or with the mco_db_load() eXtremeDB C API call.

  3. Optional XSQL check step

    Assume that database parameters are described in the corresponding xsql.cfg configuration file:

     
        xsql  -c xsql.cfg -image backupdb.bak