Wednesday, October 29, 2014

Could not insert a backup or restore history/detail record in the msdb database. This may indicate a problem with the msdb database.

The backup job of SQL Server 2008 databases started failing with below error:

Description: Error encountered during backup. Error: [Could not insert a backup or restore history/detail record in the msdb database. This may indicate a problem with the msdb database. An exception occurred while executing a Transact-SQL statement or batch.]

This error comes up due to several reasons and majority of the reasons are:

 There might be space issue in the drive\disk where database files reside or database. msdb database itself would be corrupt.

In our case both were the reasons, first when we had backup failure noticed there was space issue in drive, after releasing some space backups went fine. But after few days backups started failing again with same error, but this time there is no space issue and when tried to query backup related tables in msdb database it was throwing error basically few backup related tables in msdb are not accessible.

Msg 0, Level 11, State 0, Line 0
A severe error occurred on the current command.  The results, if any, should be discarded.
Msg 0, Level 20, State 0, Line 0
A severe error occurred on the current command.  The results, if any, should be discarded.

So we ended up restoring the msdb database with most recent available backup and that has fixed the issue. I don’t suggest rebuilding msdb  or any system database unless that’s the only option left, as this may lead to other issues. So be sure before you go for this option.



Thanks!!