CDC: CDC Hangs when I try to disable it

Problem Description:

SQL Server 2008 SP1

Transactional Replication

CDC enabled

I have an issue that occurs while trying to disable CDC on one of my databases.

When I execute the system stored procedure sys.sp_cdc_disable_db, the procedure will hang waiting on a “REPL_HISTORYCACHE_ACCESS” lock for an indefinite amount of time.

Workaround / Solution:

The cause of the issue is due to when a log reader agent is shut down, the server session of log reader (sp_replcmds) may not be shut down gracefully. It will appear as if there is an active session.

Work around is to completely stop the log reader agent before running ‘remove’ logic.

This issue will be fixed in SQL Server 2008 SP2.