P4D "-xv" Flag

Low Level Database Structure Validation

Info & Tags

Article #:
836
Created:
12/13/06
Modified:
08/19/08
Tags:
p4d

Links

  1. Recovering Your Perforce Database
    Perforce System Administrator's Guide
Warning: If you suspect Perforce database corruption, and you can not restore from a recent checkpoint and journal, call or contact Perforce support immediately. Attempting to address the issue on your own can result in the corruption or loss of your data.

SUMMARY

The "-xv" command checks the low-level structure and integrity of your Perforce database tables, and reports any errors found. The basic syntax is:
p4d -xv

DETAILS

The P4D "-xv" flag was introduced in revision 2001.1.

The Perforce Server database tables are kept in a B-tree structure, which allows rapid keyed access, and keeps the data organized. The data stored in this structure uses offsets within the file to either point to pages or to specific information within a page. Data on the pages is often relocated to accommodate new data or to reuse space from deleted items.

The structures can become damaged in the event of:
  • An unexpected server halt (crash, power outage, hardware failure).
  • Insufficient disk space.
  • Partial hardware failure (Hard drives, controllers, bad memory).
You might suspect low-level database issues if you encounter any of the following:
  • Checkpoint creation fails -- the checkpoint file itself may be present, but incomplete, and the journal file failed to truncate.
  • If items appear in a checkpoint, but are not accessible by way of Perforce client commands.
  • If P4D crashes during any operation that scans large portions of the database.
  • You receive any Perforce Server error messages with  "dbscan" or "db write" errors.
After running the -xv command you will see a series of messages as it processes each table in the format:
Validating db.name
The length of time the command takes to run varies according to the size of each table. For example, a typical "db.protect" table will validate more quickly than "db.have". In general, validating your Perforce database tables takes about the same time as taking a checkpoint. The tables are locked individually as needed during validation.

Some validation errors you might see:
  • Pages beyond the size of the file.
  • Circular free list.
  • Pages which are not readable.
  • Pages which are not connected to tree or freelist.
  • Pages which are not valid or are uninterpretable.
  • Pages which are visited multiple times in tree and freelist.
  • Data is out of order - table restore required.
  • B-tree does not have consistent level count.
  • Pages of uninterpretable contents found.
  • Items within pages have structural problems.
If any of these errors are evident you should restore from your most recent good checkpoint and journal files. If validation errors persist after the restore you should contact Perforce Support.


Note:
One validation message can be safely ignored:
  • Free list pages which are not marked as free.
This message is informational and does not indicate any problem with your data.