Error 2521

Severity

16

Message text

Versions earlier than 15.0:

Table Corrupt: Page is linked but not allocated. Run DBCC TABLEALLOC to correct the problem. (alloc page#=%ld, extent id=%ld, logical page#=%ld, object id in extent=%ld, index id in extent=%ld, object name=%S_OBJID)

Version 15.0 and later:

Table Corrupt: Page is linked but not allocated. Run DBCC %s to correct the problem. (allocation page#=%ld, extent id=%ld, logical page#=%ld, object id in extent=%ld, object name=%S_OBJID, index id in extent=%ld)

NoteThat the first substitution parameter (%s) could be either tablealloc or textalloc. The actual value that displays, tablealloc or textalloc, indicates which dbcc command should be run to correct the problem.

Explanation

This error is serious, especially if it occurs on a table’s data pages. Error 2521 indicates that a page is currently in use by a table or index but has not been marked as allocated. If the same page is allocated again, a loss of whatever data resides on the page can result.

Pages that encounter the 2521 error are not included in a database dump. This is because database dumps are performed by reading allocation pages and not by traversing page chains. Therefore, this error should be corrected before dumping the database.

NoteThe instructions below are for fixing 2521 errors. Two easy-to-use strategies exist for detecting this error earlier. Refer to “Detecting allocation errors early” in the chapter “Other Useful Tasks” in the most recent version of the guide Troubleshooting and Disaster Recovery.

Action

Occasionally dbcc checkalloc reports this error when no real error condition exists. Check to see if the error is real, or continue reading this section and take action to correct the condition even if you are unsure whether a real allocation error occurred. This error can be caused by a hardware problem.

Because the process used to determine whether the error is real can be time-consuming, you may want to go directly to “Error resolution”.


Verifying that the error is real

Run dbcc checkalloc in single-user mode if you suspect the 2521 error message are incorrect. If the error is in master, use the procedure “Starting Adaptive Server in single-user mode” in the “Server Recovery Tasks” chapter in the most recent version of the guide Troubleshooting and Disaster Recovery. Refer to “dbcc” in the Reference Manual: Commands for information about using dbcc checkalloc.


Error resolution

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

If the text of the error message includes a real object name, not a number, then the error is on an existing object to which the system catalog has correct references. Continue to “Identify table: User or system table”.

If a number appears instead of the object name, then that object only partially exists and the error must be corrected using the procedure described in “Fixing and preventing allocation errors” in the chapter “Other Useful Tasks” in the most recent version of the guide Troubleshooting and Disaster Recovery.


Identify table: User or system table

Look at the value for “object ID in extent” in the error message. If the value is 100 or greater, go to “Action for user tables.” If the “object ID in extent” is less than 100, the error occurred on a a system table and requires a different procedure described in the section “Action for system tables”.


Action for user tables

If the “object id in extent” in the error message is 100 or greater, follow these steps to correct the error:

  1. Check the value of the “index ID in extent” in the error message to determine whether it is a table (the value is 0 (zero)) or an index (with a value between 0 (zero) and 255).

  2. Run dbcc tablealloc or dbcc indexalloc, depending on whether the object named in the 2521 error is a table or an index. Before you run the appropriate command, keep in mind:

    • dbcc tablealloc can correct this problem on a table or an index, but if the problem is on an index, you can avoid affecting the entire table by using the dbcc indexalloc command. If the table is large or heavily used, it may be more practical to use dbcc indexalloc.

    • These commands correct the error only when run in the full or optimized mode. Do not specify the nofix option or the 2521 error will not be corrected.

    • Use either the “object name” or “object ID in extent” values from the error message in the commands above where the argument “object_name” appears.

    Use the command appropriate for your situation:

    Tables (index id in extent = 0)

    Indexes (0 < index ID in extent < 255)

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

    1> dbcc indexalloc (<object_name>, 2> <index_id_in_extent>) 3> go

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


Action for system tables

If the “object ID in extent” in the error message is less than 100, perform these steps:

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

    • If the database is master, use the procedure “Starting Adaptive Server in single-user mode” in the “Server Recovery Tasks” chapter in the most recent version of the guide Troubleshooting and Disaster Recovery, then continue with this procedure.

    • 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. Check the value of the “index ID in extent” in the error message to determine whether it is a table (the value is 0 (zero)) or an index (the value is greater than 0 (zero).

  3. Run dbcc tablealloc or dbcc indexalloc, depending on whether the object named in the 2521 error message is a table or an index. Before you run the appropriate command, keep in mind:

    • dbcc tablealloc can correct either a table or an index, but if the problem is on an index, you can avoid affecting the entire table by using the dbcc indexalloc command. If you need to minimize the amount of time the table is unavailable, it may be more practical to use dbcc indexalloc.

    • These commands correct the error only when run in the full or optimized mode, with the fix option specified. This is necessary because the default value is nofix when these commands are run on system tables.

    • Use either the “object name in extent” or “object id” values from the error message in the commands above where the argument “object_name” appears.

      Use the command appropriate for your situation:

      Tables (index ID in extent = 0)

      Indexes (0 < index ID in extent < 255)

      1> dbcc tablealloc (<object_name>, 2> full, fix) 3> go

      1> dbcc indexalloc (<object_name>, 2> <index_id_in_extent>, full, fix) 3> go

  4. Turn off single-user mode in the database:

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

    • If the database is not master, use this 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 the dbcc tablealloc and dbcc indexalloc commands.

Versions in which this error is raised

All versions