Next: , Previous: , Up: Crash Tolerance   [Contents][Index]


17.5 Manual crash recovery

Manual recovery is usually performed with the help of the gdbmtool utility. Start gdbmtool in read-only mode (the -r) option. Once in the command shell, issue the following command:

snapshot a b

where a and b are names of the two snapshot files you configured using the gdbm_failure_atomic function. This command investigates both files and prints out detailed diagnostics.

Its output begins with a line listing one of the error codes above, followed by a colon and a textual description of the error. The lines that follow show details for each snapshot file.

Each snapshot description begins with the snapshot file name followed by a colon and four fields, in this order:

  1. File permission bits in octal.
  2. File permission bits in ls -l notation.
  3. Modification timestamp.
  4. Numsync counter. For databases in standard GDBM format, this field is ‘N/A’. If the counter cannot be obtained because of error, this field is ‘?’.

Any errors or inconsistencies discovered are reported in the lines that follow, one error per line. Here’s an example of the snapshot command output, describing the GDBM_SNAPSHOT_ERR condition:

gdbmtool> snapshot even.dbf odd.dbf
GDBM_SNAPSHOT_ERR: Error selecting snapshot.
even.dbf: 200 -w------- 1627820627.485681330 ?
odd.dbf: 600 rw------- 1627820627.689503918 301
odd.dbf: ERROR: bad file mode

Line 2 lists the meta-data of the snapshot even.dbf. The numsync field contains question mark because the file permissions (write-only) prevented gdbmtool from opening it.

The lines for odd.dbf show the actual reason for the error: bad file mode (read-write). Apparently, the file mode has been changed manually after the crash. The timestamp of the file, which is more recent than that of even.dbf, suggests that it might be used for recovery. To confirm this guess, change the mode of the even.dbf to read-only and repeat the snapshot command:

gdbmtool> ! chmod 400 even.dbf
gdbmtool> snapshot even.dbf odd.dbf
GDBM_SNAPSHOT_ERR: Error selecting snapshot.
even.dbf: 400 r-------- 1627820627.485681330 300
odd.dbf: 600 rw------- 1627820627.689503918 301
odd.dbf: ERROR: bad file mode

This shows the numsync value of the even.dbf file, which is exactly one less than that of odd.dbf. This means that the latter should be selected for recovery.

For completeness sake, you can change the mode of odd.dbf to read-only as well and repeat the snapshot command. In this case you will see:

gdbmtool> ! chmod 400 odd.dbf
gdbmtool> snapshot even.dbf odd.dbf
GDBM_SNAPSHOT_OK: Selected the most recent snapshot.
odd.dbf: 400 r-------- 1627820627.689503918 301

Next: , Previous: , Up: Crash Tolerance   [Contents][Index]