Over the weekend I was troubleshooting an issue and found that part of it was being caused by corruption on one of my databases. I have seen DBCC CheckDB fix corruption a few times and thought, “No problem, I’ve got this.”
ALTER DATABASE CorruptDB SET SINGLE_USER WITH ROLLBACK IMMEDIATE; BEGIN TRANSACTION; DBCC CHECKDB ('CorruptDB', REPAIR_REBUILD); ALTER DATABASE CorruptDB SET MULTI_USER; COMMIT
I waited for it to finish because the rule is, “Let it finish”.
There were still errors. So I ran it again.
The same errors appeared saying that some errors were waiting on others to be fixed first. But nothing had fixed and my heart sank. I had a moment of panic as I furiously googled. I saw post after post telling me to restore the backup…Did I mention the small problem that the corruption had prevented the backups from completing for this database but didn’t throw an error? My backups were over two weeks old and a roll back was not an option.
I found a post by Paul Randal from 2006 talking about when DBCC CheckDB won’t solve the issue. He mentioned that sometimes it is just an index or statistic that is corrupted. This gave me hope and I started tracing my error. I found it was on a Change Data Capture table that is being used in our replication. I began pondering an idea. I removed replication and ran the DBCC CheckDB. It was clean! No corruption! I breathed and took a backup. Then I added replication back on and ran the DBCC CheckDB again. It was clean again! Everything was healthy and fine!
Thank you to everyone for your past posts that save my sanity and thank you for DBCC CheckDB!!!
The song for this post is Someone You Loved by Lewis Capaldi