Title: SQL Server 2022 Developer Edition — Cannot disable CDC on database, sp_cdc_disable_db fails with error 3930 (sp_replhelp transaction conflict)
Environment
- SQL Server 2022 Developer Edition (RTM) — 16.0.1000.6, Windows Server 2022
- Standalone instance (not a cluster, not an AG)
- Target: AWS RDS SQL Server 2022 Custom Engine Version (CEV)
16.00.4215.2.sql-server-dev-ed-cev
- Database:
DB_Stage (~14GB, partitioned across multiple filegroups by year 2020–2040+)
Background
I'm migrating a SQL Server 2022 Developer Edition database to AWS RDS SQL Server using native backup/restore (rds_restore_database). The source database has is_cdc_enabled = 1 in sys.databases, but AWS RDS's post-restore CDC cleanup fails with a 3930 transaction error, causing the entire restore task to abort with lifecycle=ERROR — even though RESTORE DATABASE itself reports full success (all pages processed).
I need to either:
- Clear
is_cdc_enabled to 0 on the source before taking the backup, OR
- Understand why
sp_cdc_disable_db is failing and how to fix it
The Core Problem
EXEC sys.sp_cdc_disable_db consistently fails with:
Msg 22831, Level 16, State 1, Procedure sys.sp_cdc_disable_db_internal, Line 338
Could not update the metadata that indicates database DB_Stage is not enabled for Change Data Capture. The failure occurred when executing the command '.sys.sp_replhelp N'DisablePerDbHistoryCache''. The error returned was 3930: 'The current transaction cannot be committed and cannot support operations that write to the log file. Roll back the transaction.'
Diagnostic findings
1. CDC objects don't exist:
SELECT * FROM cdc.change_tables;
The database has is_cdc_enabled = 1 but no CDC capture instances or CDC schema objects exist. This is an inconsistent/orphaned state.
2. No blocking transactions:
SELECT session_id, open_transaction_count, status, blocking_session_id
FROM sys.dm_exec_requests WHERE open_transaction_count > 0;
3. Log reuse wait is benign:
SELECT name, log_reuse_wait_desc FROM sys.databases WHERE name = 'DB_Stage';
4. Replication not configured on this database:
SELECT name, is_published, is_subscribed, is_merge_published
FROM sys.databases WHERE name = 'DB_Stage';
5. However — orphaned distributor was configured on the server:
EXEC sp_helpdistributor;
Ran EXEC sp_dropdistributor = 1, u/ignore_distributor = 1 — succeeded, distributor removed. sp_cdc_disable_db still fails with the same error afterward.
6. CDC Agent jobs existed (duplicate cleanup job):
STAGE-SQL-DB_Stage-1
cdc.DB_Stage_capture
cdc.DB_Stage_cleanup
cdc.DB_Stage_cleanup.E2CB2DD4-8F29-4E57-B457-813E290E1A8C ← duplicate
Disabled all four jobs via sp_update_job u/enabled = 0. Still fails.
7. Stopped SQL Server Agent service entirely.
Still fails.
8. Restarted SQL Server service.
Still fails — is_cdc_enabled persists at 1 after restart as expected (it's a persisted DB property).
9. Tried allow updates + direct catalog update via DAC:
EXEC sp_configure 'allow updates', 1; RECONFIGURE WITH OVERRIDE;
UPDATE sys.sysdatabases SET category = category & ~0x100 WHERE name = 'DB_Stage';
Not supported in SQL Server 2022.
The sp_replhelp angle
sp_cdc_disable_db_internal internally calls sp_replhelp N'DisablePerDbHistoryCache'. This proc is part of the replication infrastructure. Even after removing the orphaned distributor, this call still fails with 3930 — suggesting there's either:
- A stale replication context cached somewhere in the database itself
- An internal transaction started by
sp_cdc_disable_db_internal that is already in a doomed/rollback-only state before sp_replhelp is called
- A conflict between the CDC disable transaction and the database's log state
The
3930 error specifically means "the current transaction cannot be committed and cannot support operations that write to the log file" — which points to a transaction that has already been marked for rollback trying to write CDC metadata.
AWS RDS impact
When restoring this backup to RDS via rds_restore_database, RDS runs post-restore CDC cleanup internally. This hits the same 3930 error and RDS aborts the entire task:
Could not update the metadata that indicates database [name] is not enabled
for Change Data Capture. The failure occurred when executing the command '(null)'.
The error returned was 3930
S3 processing has been aborted
lifecycle = ERROR
RESTORE DATABASE reports full success (1,843,815 pages in ~138 seconds) but RDS discards the restored database. This happens regardless of the target database name.
Questions
- Why would
sp_replhelp fail with 3930 inside sp_cdc_disable_db_internal when there are no open transactions, no active replication, and the distributor has been removed?
- Is there any way to force-clear
is_cdc_enabled on a database where sp_cdc_disable_db cannot complete — without taking the server offline or restoring to a new database?
- Is this a known bug in SQL Server 2022 RTM (16.0.1000.6)? The instance is unpatched — would applying CU14+ resolve this?
- Is there an internal system procedure or trace flag that can bypass the
sp_replhelp call inside sp_cdc_disable_db_internal?
EDIT: Updated formatting and removed some identifying snippets in the body. Thank you to anyone who read this far.