Data Validation and Repair - Firebird

In day-to-day operation, a database is sometimes subjected to events that pose minor problems to database structures. These events include

  • Abnormal termination of the server. The integrity of the database is not affected by an abnormal termination. However, if Firebird has already assigned a data page for uncommitted changes requested by clients, the page becomes an “orphan.” While orphan pages are quite benign, they occupy unassigned disk space that should be returned to free space. Validation can find and release these spaces.
  • Write errors in the operating system or hardware. Write errors usually create problems for database integrity. They can cause data structures such as database pages and indexes to become broken or lost. At worst, these corrupt data structures can make committed data irrecoverable. Sometimes, validation may be able to help find these broken pieces and eliminate them.

When to Validate a Database

You should validate a database

  • Whenever a database backup is unsuccessful
  • Whenever an application receives a “corrupt database” error
  • Periodically, as a regular housekeeping routine, to monitor for corrupt data structures or misallocated space
  • Any time you suspect data corruption

The command-line utility gbak can be used in conjunction with gfix to perform a sequence of validation and repair steps.

Performing a Database Validation

Database validation requires exclusive access to the database. Without exclusive access, you get the error message

OBJECT database_name IS IN USE

To validate a database, simply enter the command

gfix -v

Validation will silently locate and free any unassigned pages or misallocated structures it finds. It will report any corrupt structures but does not attempt to mend them. To have gfix report faults but not attempt to free the spaces, include the –n[o_update] switch:

gfix -v -n

You can have the validation ignore checksum errors by adding the –i[gnore] switch:

gfix -v -i

Repairing a Corrupt Database

If you suspect you have a corrupt database, it is important to follow a proper sequence of recovery steps in order to avoid further corruption.

For a description of the gfix switches to use during this recovery procedure, refer to Table.

All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd Protection Status

Firebird Topics