Skip to Content
Technical Articles
Author's profile photo Vivek Sahu

HANA – Consistency Check of the Persistence (hdbpersdiag)

Introduction (hdbpersdiag)

Both understanding the root cause of the corruption and resolving it is very important. You may not be able to resolve a corruption if you don’t understand how it is introduced, and you may have new corruptions if you haven’t understood and resolved the root cause of previous corruptions.

Consistency check in logical layer of database is checked via :

CALL CHECK_TABLE_CONSISTENCY('CHECK',NULL,NULL)

But, there is also a mechanism to diagnose corruptions at physical level. hdbpersdiag tool is a persistence-based check method that will check structure-based aspects of the persistence only. It can be executed for all data volumes. Downtime is needed to run the consistency check of hana persistence and hana instance must also be stopped before executing the tool. Trace for hdbpersdiag tool is written by default into the database trace directory.

Syntax

The tool hdbpersdiag is an expert tool and only the “check all” option is meant for public use. Make sure that you only use it if you know what you do.It is delivered as part of the standard SAP HANA installation in directory /usr/sap/<sid>/HDB<inst_id>/exe.

hdbpersdiag -c 'check all' <DATA_VOLUME_PATH>

Attention: Needs additional memory of up to 2 % of the data volume size (worst case if many small 4 KB pages exist)

Example

  1. If persistence encryption is enabled for your SAP HANA database, use it like below :
    <sid>adm@<host>:/usr/sap/<SID>/HDB02> hdbpersdiag -c -e 'check all' /hana/data/<SID>/mnt00001/hdb00001
    Loaded library 'libhdbunifiedtable'
    Loaded library 'libhdblivecache'
    Trace is written to: /usr/sap/<SID>/HDB02/<host>/trace
    Mounted DataVolume(s)
      #0 /hana/data/<SID>/mnt00001/hdb00001/ (8.2 GB, 8809873408 bytes)
    Tips:
      Type 'help' for help on the available commands
      Use 'TAB' for command auto-completion
      Use '|' to redirect the output to a specific command. Available command(s) are:
        count        Count the number of lines
        dump         Save the output to a file
        grep         Print lines that contain a match for a pattern
        head         Print the first n lines
        more         Print text, one screen at a time
        tail         Print the last n lines
    INFO: KeyPage loaded and decrypted with success
                         Default Anchor Page OK
                                Restart Page OK
                           Default Converter OK
                          RowStore Converter OK
                Logical Pages (308900 pages) OK
                       Logical Pages Linkage OK
                          ContainerDirectory OK
                      ContainerNameDirectory OK
                      FileIDMappingContainer OK
                           UndoFileDirectory OK
                       LOBContainerDirectory OK
                MidSizeLOBContainerDirectory OK
                   LOBFileIDMappingContainer OK​
  2. If persistence encryption is not enabled, use like below:
    <sid>adm@<host>:/usr/sap/<SID>/HDB02> hdbpersdiag -c 'check all' /hana/data/<SID>/mnt00001/hdb00001
    Loaded library 'libhdbunifiedtable'
    Loaded library 'libhdblivecache'
    Trace is written to: /usr/sap/<SID>/HDB02/<host>/trace
    Mounted DataVolume(s)
      #0 /hana/data/<SID>/mnt00001/hdb00001/ (8.2 GB, 8809873408 bytes)
    Tips:
      Type 'help' for help on the available commands
      Use 'TAB' for command auto-completion
      Use '|' to redirect the output to a specific command. Available command(s) are:
        count        Count the number of lines
        dump         Save the output to a file
        grep         Print lines that contain a match for a pattern
        head         Print the first n lines
        more         Print text, one screen at a time
        tail         Print the last n lines
    INFO: KeyPage loaded and decrypted with success
                         Default Anchor Page OK
                                Restart Page OK
                           Default Converter OK
                          RowStore Converter OK
                Logical Pages (308900 pages) OK
                       Logical Pages Linkage OK
                          ContainerDirectory OK
                      ContainerNameDirectory OK
                      FileIDMappingContainer OK
                           UndoFileDirectory OK
                       LOBContainerDirectory OK
                MidSizeLOBContainerDirectory OK
                   LOBFileIDMappingContainer OK

If you encounter any corruption during above checks, report it to SAP via customer message for further troubleshooting and solution.

Recommendation for Production Systems

In a productive environment, if you want to to check the consistency of the persistence of a system, prefer an indirect approach by using backup-recovery into non-prod system:

  1. Take a new full backup of the system which you want to check.
  2. Recover the backup in a non-prod environment that you want to use for the check.
  3. Shut down the system that you have just recovered.
  4. Run hdbpersdiag for all data volumes (one-by-one) which you want to check:
    hdbpersdiag -c ‘check all’ <DATA_VOLUME_PATH>

Assigned tags

      2 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Ruslan Muhometyarov
      Ruslan Muhometyarov

      Hi All!

      When the command is executed, the datavolume is copied to /tmp/PersDiag
      How do I change the default path?

      Example command:

      ******************

      /usr/sap/<SID>/HDB<NO>/exe/hdbpersdiag -c ‘check all’ –tracedir /hana/PersTEMP2/ /hana/data/<SID>/mnt00001/hdb00003/datavolume_0000.dat
      Loaded library ‘libhdbunifiedtable’
      Loaded library ‘libhdblivecache’
      Trace is written to: /hana/PersTEMP2/
      INFO: File /hana/data/<SID>/mnt00001/hdb00003/datavolume_0000.dat copied to /tmp/PersDiag/node0/
      Mounted DataVolume(s)
      #0 /tmp/PersDiag/node0/ (256.0 MB, 268435456 bytes)
      Tips:
      Type ‘help’ for help on the available commands
      Use ‘TAB’ for command auto-completion
      Use ‘|’ to redirect the output to a specific command. Available command(s) are:
      count Count the number of lines
      dump Save the output to a file
      grep Print lines that contain a match for a pattern
      head Print the first n lines
      more Print text, one screen at a time
      tail Print the last n lines
      Default Anchor Page OK
      Restart Page OK
      Default Converter Pages OK
      Static Converter Pages OK
      RowStore Converter Pages OK
      Logical Pages (8194 pages) OK
      Logical Pages Linkage OK
      INFO: Container directory of type (‘ContainerDirectory’) is empty.
      UndoFileDirectory OK
      DRLoadedTable OK

      ************************

      HANA 2.0 SPS05 rev. 051

      Author's profile photo Vivek Sahu
      Vivek Sahu
      Blog Post Author

      Hello Ruslan Mukhometyarov

      I tried to reproduce the scenario here and was able to find the root cause for your issue. You can avoid this by skipping the .dat file into path provided, because if you will provide the volume name it will be copied to /tmp directory.

      Your command :
      /usr/sap/<SID>/HDB<NO>/exe/hdbpersdiag -c ‘check all’ –tracedir /hana/PersTEMP2/ /hana/data/<SID>/mnt00001/hdb00003/datavolume_0000.dat

      Command to be used :
      /usr/sap/<SID>/HDB<NO>/exe/hdbpersdiag -c ‘check all’ –tracedir /hana/PersTEMP2/ /hana/data/<SID>/mnt00001/hdb00003

      This will execute the check on data volume path only and will not be copied else where.

      Best Regards,
      Vivek Sahu