Previous Topic: How to Respond to an Alert for File Size or File Full

Next Topic: NetMaster Database Administration

Fix a Corrupted NDB

An NDB may become corrupted by an NDB full or region cancelled event. To recover the data, you must use the NDB ALTER OPT=BLDX command to rebuild the indexes.

Note: This procedure e following steps are from the IPLOG file and apply to all NDBs.

To fix a corrupted NDB

  1. Create a work file. The size must relate to the number of records in the NDB.

    The following shows some sample JCL:

    //DEFWRK   EXEC  PGM=IDCAMS

    //SYSPRINT DD  SYSOUT=*
    //SYSIN    DD  *
     DELETE (hlq.TEST.NDBWORK) CL
     DEFINE CLUSTER (NAME(hlq.TEST.NDBWORK)      -  
                     MGMTCLAS(DEFAULT)           -  
                     STORCLAS(NMDPOOL)           -  
                     INDEXED                     -  
                     RECORDS(1000000 100000)     -  
                     SPEED                       -  
                     SHAREOPTIONS(2 3)           -  
                    )                            -  
            DATA    (NAME(hlq.TEST.NDBWORK.D)    -  
                     CONTROLINTERVALSIZE(4096)   -  
                     RECORDSIZE(1017 4089)       -  
                     FREESPACE(0 0)              -  
                     KEYS(4 0)                   -  
                    )                            -  
            INDEX   (NAME(hlq.TEST.NDBWORK.I)    -  
                     CONTROLINTERVALSIZE(1024))     
    /*
    
  2. Issue the following command from OCS to allocate the work file to the region:
    ALLOCATE DD=NDBWORK DSN=hlq.TEST.NDBWORK DISP=SHR
    

    Issue the following command to open the work file as a VSAM file.

    UDBCTL OPEN=NDBWORK STRNO=3 BUFNI=5 BUFND=6
    
  3. Issue the following command to remove the NDB bad-locked status:
    NDB PURGE IPLOG
    
  4. Issue the following command to stop the NDB to prevent access:
    NBD STOP IPLOG IMM
    
  5. Issue the NDB ALTER command to check the indexes, as follows:
    NDB ALTER IPLOG OPT=CHKX DB WORK=NDBWORK DETAIL=YES SORT=100000
    

    Minimizing I/O on the work file by specifying the maximum value for sort memory reduces execution time.

  6. Issue the following command to close and free the work file:
    UDBCTL CLOSE=NDBWORK
    UNALLOC DD=NDBWORK
    
  7. Check the CHKX, and if it shows an error, rebuild the indexes by redefining the work file to empty it, and then use the BLDX option of NDB ALTER, by issuing the following command:
    NDB ALTER IPLOG OPT=BLDX DB WORK=NDBWORK DETAIL=YES SORT=100000
    

    Minimizing I/O on the work file by specifying the maximum value for sort memory reduces execution time.

  8. Reallocate the NDB by actioning the IPFILES - TCP/IP File Specifications Customizer Parameter Group.

    If the NDB ALTER BLDX action fails, and needs to be rerun, the work file must be unallocated and redefined.