A SQL Server Instance was shut down suddenly. When the SQL Server recovery a number of databases were in a RECOVERY_PENDING state.
The error messages in the SQL Server Error Log were :
--An example error message Log file 'F:\MSSQLSERVER\MSSQL$MYINST\Data\db1_log.LDF' does not match the primary file. It may be from a different database or the log may have been rebuilt previously. Error: 5173, Severity: 16, State: 1. One or more files do not match the primary file of the database. If you are attempting to attach a database, retry the operation with the correct files. If this is an existing database, the file may be corrupted and should be restored from a backup.
RECOVERY_PENDING means “Recovery of the file has been postponed. The file was online or did not exist before being changed to RECOVERY_PENDING by a partial restore”
Main reasons for database stuck in RECOVERY_PENDING after a sudden shutdown
1) Log is missing
2) Log is corrupt
3) Drive not online
1) If the drive is available and online – try a SQL Server restart , as the drive may have been unavailable during restart
2) If the restart doesn’t solve the problem , then RESTORE from a valid BACKUP
3) A Workaround For Error: 5173, Severity: 16, State: 1 try :
a) Detach the database
b) Delete the LDF file
c) Reattach the database again