Analyzing a data page

Analyze the data page when you have a REPAIR, DSN1COPY or DSN1PRNT dump of the inconsistent page.

About this task

To determine whether a data page is damaged, you probably must check the page header, the ID map, the records and holes, and the total free space by working through the procedure that follows. If you find an error, continue checking all areas because other errors might exist as well. All errors must be resolved to restore the page to a consistent state.

The following figure illustrates the structure of a data page.

Figure 1. Format of file page set data page
Begin figure description. The figure displays the file page set data page format. End figure description.

Follow all steps in this procedure, even after you detect an error. All errors must be resolved, not just the first one you find. If data sharing, the relative byte address (RBA) field should have an LRSN value.

Procedure

To analyze a data page:

  1. Check the page header (PGHEAD)
    • Check PGCOMB, a 1-byte field at offset X'00'.
      • If Bit 3 = B'1', the last byte in the page must be X'D5'.
      • If Bit 3 = B'0', the last byte in the page must be X'C5'.
    • Check PGFLAGS, a 1-byte field at offset X'0B'.
      • If Bit 0 = B'1', the data manager (DM) set the broken bit on to indicate a damaged page.
      • If Bit 0 = B'0', the DM did not set the broken bit. However, a problem can still exist.
      • Bits 1 and 5 should be B'0', indicating a data page.
      • If Bit 3 = B'1', the page is a space map page of either a segmented (Bit 2 is also B'1') or nonsegmented file page set. Do not follow the remaining procedures. Call an IBM® support center.
  2. Check whether the Db2 directory (DSNDB01) is involved.
    • Check PGNANCH, a one-character field at offset X'13'.

      If PGNANCH > X'00', bit 4 of PGFLAGS (at offset X'0B') must be B'1', indicating that the page is a hash page in the Db2 directory. PGNANCH contains the number of 8-byte anchors points in the page. Each anchor point contains a forward and backward pointer. For all anchors points, verify that either both pointers are X'00000000' or both pointers contain valid record identifiers (RIDs). A valid RID has a nonzero value in the first 3-byte portion and a nonzero value in the last byte.

  3. Define three working variables:
    • #IDS to accumulate the number of ID map entries.
    • TOTAL HOLE to accumulate the total amount of storage that is contained in holes.
    • CURRENT OFFSET to accumulate the offset to the part of the page that is being analyzed.
  4. Analyze the space that contains records and holes, which begins at offset X'14' + (8PGNANCH).
    This space ends at the offset stored in PGFREEP (a two-character field at offset X'0E'). Starting with the first record or hole, perform the following checks, depending on what is stored in the page at the current point of interest.
    1. Record or Overflow Record (first byte is X'00' or X'20'):
      • Verify that the ID map entry whose number is contained in PGSBID (a one-character field at offset X'05') contains the offset of this record. Add 1 to the value currently in the working variable that named #IDS.
      • Add the value in PGSLTH (a two-character field at offset X'01' in the record) to CURRENT OFFSET to get the offset to the next record or hole.
    2. Pointer Record (first byte is X'40'):
      • Add 6 bytes to CURRENT OFFSET to get the offset to the next record or hole.
    3. Large Hole (first byte is X'80'):
      • Add the value in PGHLTH (a two-character field at offset X'01' in the hole) to TOTAL HOLE.
      • Add the value in PGHLTH to CURRENT OFFSET to get the offset to the next record or hole.
    4. Small Hole (first byte is X'81', X'82', X'83' or X'84'):
      • Add the length of the hole to TOTAL HOLE. The length is the value of the second nibble in the first byte (for example, the first byte of a 2-byte short hole is X'82').
      • Add the length to CURRENT OFFSET to get the offset to the next record or hole.

    Repeat these steps until CURRENT OFFSET is equal to the value in PGFREEP.

  5. Analyze the chain of large holes by checking PGHOLE1, a two-character field at offset X'10' in the data page. If PGHOLE1 is not X'0000', use the value in PGHOLE1 as the offset to the first hole, and perform the following tests:
    1. Verify that a large hole is at the offset (the value of the first byte should be X'80').
    2. Use the value in PGHCHAIN (a two-character field at offset X'03' of the large hole) as the offset to the next hole and repeat this step if PGHCHAIN > X'0000'. If PGHCHAIN = X'0000', continue with the next step.
  6. Analyze the ID map and page tail area. If not all existing ID map entries are in use (#IDS (used entries) does not equal PGMAXID (used + free entries)), the next-to-the-last byte in the page should contain the number of the first free ID map entry in the chain.
    1. The ID map entry pointed to should not be currently in use (high-order bit should be on).
    2. Use the low-order portion of the free ID map entry as an ID map entry number, and repeat these steps until you reach the end of the chain of free ID map entries.
  7. Verify PGMAXID, a one-character field at offset X'12' of the page, contains the number of ID map entries that have been allocated, including both used and free entries.
  8. Verify PGFREE, a two-character field at offset X'0C' of the page, contains the amount of total free space in the page.
    • For 4-KB pages (X'1000', or 4096, bytes):
      free space = X'1000' - X'02' for tail area
                   - (2PGMAXID) - PGFREEP
                   + X'TOTAL HOLE' = PGFREE
    • For 8-KB pages (X'2000', or 8192, bytes):
      free space = X'2000' - X'02' for tail area
                   - (2PGMAXID) - PGFREEP
                   + X'TOTAL HOLE' = PGFREE
    • For 16-KB pages (X'4000', or 16384, bytes):
      free space = X'4000' - X'02' for tail area
                   - (2PGMAXID) - PGFREEP
                   + X'TOTAL HOLE' = PGFREE
    • For 32-KB pages (X'8000', or 32768, bytes):
      free space = X'8000' - X'02' for tail area
                   - (2PGMAXID) - PGFREEP
                   + X'TOTAL HOLE' = PGFREE

      PGMAXID, at offset X'12' of the page, contains the number of allocated ID map entries. PGFREEP, at offset X'0E' of the page, contains the offset to the contiguous free space in the page. TOTAL HOLE is the figure that you computed in Step 4 for the total space that is occupied by holes in the page.

Results

If you found errors and determined what must be modified by way of the REPAIR utility, continue with Running REPAIR. If no errors or inconsistencies were detected, the page is probably not damaged.