Error 7940

Severity

22

Message text

The counts in the OAM are incorrect.  This implies that there are entries missing.  Run tablealloc utility with the FIX option on the table with the inaccurate OAM counts.

Explanation

This error is raised when Adaptive Server detects that the total page count in the object allocation map (OAM) is different from the actual number of pages in the chain. This problem is detected by dbcc checkalloc, dbcc tablealloc, and dbcc indexalloc.

This error can result in various run-time failures and should be corrected; however, if no other errors are occurring, you can wait to correct the problem until non-peak hours.

NoteThe instructions below are for fixing 7940 errors once they have occurred. Two easy-to-use strategies exist for detecting this error sooner in the future. Refer to “Detecting allocation errors early” in the chapter “Other Useful Tasks” in the most recent version of Troubleshooting and Disaster Recovery for information about these strategies.

Action

Occasionally dbcc checkalloc reports this error when no real error condition exists. You can either check to see if these errors are real, or continue with this section and take action to correct them, whether or not they reflect a real allocation error.

Because the process used to discover whether or not the errors are real can be time-consuming, you may want to go directly to the “Error Resolution” section now.


Verifying that the error is real

Run dbcc checkalloc in single-user mode if you suspect the 7940 error messages are incorrect. If the error is in master, use the section “Starting Adaptive Server in single-user mode” in the chapter “Server Recovery Tasks” in the most recent version of Troubleshooting and Disaster Recovery for instructions about how to invoke Adaptive Server in single-user mode. Refer to “Checking Database Consistency” in the System Administration Guide: Volume 2 for information about dbcc checkalloc.


Error resolution

If many of these errors are occurring, it is possible to clear them all at once by using the dbcc checkalloc with fix option command. Refer to “Fixing and preventing allocation errors” in the chapter “Other Useful Tasks” in the most recent version of the Troubleshooting and Disaster Recovery for information about using dbcc checkalloc.


Identify table: User or system table

Get the table name that the error occurred on from the original output which indicated this error. If it is a user table, continue with “Action for user tables.” If it is a system table, it requires a different procedure described in “Action for system tables.”


Action for user tables

Run dbcc tablealloc. This command can correct the error only when run in the full or optimized mode, and with the nofix option not specified (the default for user tables):

1> dbcc tablealloc (<table_name>)
2> go

Refer to “dbcc” in the Reference Manual: Commands and “Checking Database Consistency” in the System Administration Guide: Volume 2 for information about dbcc tablealloc.


Action for system tables

  1. Put the affected database in single-user mode:

    • If the database is master, use the procedure in “Starting Adaptive Server in single-user mode” in the chapter “Server Recovery Tasks” in the most recent version of Troubleshooting and Disaster Recovery, then go to step 2.

    • If the database is not master, use the sp_dboption stored procedure to put the affected database in single-user mode:

      1> use master 
      2> go
      
      1> sp_dboption <database_name>, single, true
      2> go
      
      1> use <database_name> 
      2> go
      
      1> checkpoint
      2> go
      
  2. Run dbcc tablealloc. This command corrects the error only when run in the full or optimized mode, with the fix option specified, because the default value is nofix on system tables:

    1> dbcc tablealloc (<table_name>, full, fix)
    2> go
    
  3. Turn off single-user mode in the database:

    • If the database is master, use “Returning Adaptive Server to multiuser mode” in the chapter “Server Recovery Tasks” in the most recent version of the Troubleshooting and Disaster Recovery.

    • If the database is not master, use the following procedure:

      1> use master 
      2> go
      
      1> sp_dboption <database_name>, single, false
      2> go
      
      1> use <database_name> 
      2> go
      
      1> checkpoint
      2> go
      

Refer to “dbcc” in the Reference Manual: Commands and “Checking Database Consistency” in the System Administration Guide: Volume 2 for information about dbcc tablealloc.

Versions in which this error is raised

All versions