Skip to main content

Enable CDC in SQL Server and fix empty change tables

You ran sys.sp_cdc_enable_db and sys.sp_cdc_enable_table, both returned without an error, and the change table has no rows. On SQL Server that is what a stopped SQL Server Agent looks like: the calls succeed and nothing reads the transaction log.

This page is written by the team behind OLake Go, which reads Microsoft SQL Server change logs. The steps apply to any tool that reads them and need nothing from OLake Go. OLake is not affiliated with Microsoft.

The short answer. Change data capture (CDC) needs three things, and the change table stays empty without the third:

  • The database enabled with sys.sp_cdc_enable_db by a member of sysadmin.
  • Each table enabled with sys.sp_cdc_enable_table by a member of db_owner.
  • SQL Server Agent running. It is disabled by default on Linux and in containers, and both procedures succeed without it.

Changes made while the Agent is stopped are not lost. They stay in the transaction log, and the capture job reads them once it runs.

sql
USE cdclab;
EXEC sys.sp_cdc_enable_db;
EXEC sys.sp_cdc_enable_table
@source_schema = N'dbo', @source_name = N'orders',
@role_name = NULL, @supports_net_changes = 1;

-- SQL Server Agent must be Running, or cdc.dbo_orders_CT stays empty
SELECT servicename, status_desc, startup_type_desc FROM sys.dm_server_services;

Key takeaways

  • With the Agent stopped, enabling still succeeds and creates both jobs. The only hint is the line SQLServerAgent is not currently running so it cannot be notified of this action.
  • In the run the change table held 0 rows and sys.fn_cdc_get_max_lsn() returned NULL until the Agent started. Every change made in the meantime was then captured.
  • A change table keeps the columns it had when the table was enabled. A new column needs a second capture instance, and a table can have two at most.

What you see​

Either the enable calls succeed and the change table stays empty, or a call fails with a message number. Each points at one issue:

IssueWhat you see
1. Enabling CDC failsMsg 22901, 22902, 22904, 22906, 22830 or 22939 from sys.sp_cdc_enable_db or sys.sp_cdc_enable_table
2. The change table stays emptyNo error, only SQLServerAgent is not currently running so it cannot be notified of this action., and 0 rows in the change table
3. Msg 313 when reading changesAn insufficient number of arguments were supplied for the procedure or function cdc.fn_cdc_get_all_changes_ ...
4. Schema evolution needs a new capture instanceNo error. The column is missing from the change table, and a third capture instance gives Msg 22962

The same messages on 2022 and 2019​

SQL Server 2022 (16.0.4305.5) and SQL Server 2019 (15.0.4510.2) gave the same text for every message below. Only the procedure line number in the message header differs, for example Procedure sys.sp_cdc_enable_db_internal, Line 281 on 2022 and Line 258 on 2019.

MessageTextWhat caused it in the run
Msg 22901The database 'cdclab' is not enabled for Change Data Capture. Ensure that the correct database context is set and retry the operation. ...A table was enabled before its database
Msg 22902Caller is not authorized to initiate the requested action. Sysadmin privileges are required.sys.sp_cdc_enable_db by a db_owner who is not sysadmin
Msg 22904Caller is not authorized to initiate the requested action. DBO privileges are required.sys.sp_cdc_enable_table by a user outside db_owner
Msg 22906The database 'lab_schema' cannot be enabled for Change Data Capture because a database user named 'cdc' or a schema named 'cdc' already exists in the current database. ...A schema named cdc existed
Msg 22830 with 15517Could not update the metadata that indicates database lab_owner is enabled for Change Data Capture. ... The error returned was 15517: ...The login that owned the database no longer existed
Msg 22830 with 229... The failure occurred when executing the command 'create user cdc'. The error returned was 229: ...A database trigger on data definition language (DDL) statements wrote to a table in master
Msg 22939The parameter @supports_net_changes is set to 1, but the source table does not have a primary key defined and no alternate unique index has been specified.Net changes were asked for on a table with no key
No number shownSQLServerAgent is not currently running so it cannot be notified of this action.A table was enabled, or a job was started, with the Agent stopped
Msg 313An insufficient number of arguments were supplied for the procedure or function cdc.fn_cdc_get_all_changes_ ... .A log sequence number (LSN) outside the valid range, or an unknown row filter
Msg 22962Two capture instances already exist for source table 'dbo.orders'. A table can have at most two capture instances. ...A third capture instance was requested

Msg 22830 is a wrapper. The command and the inner error at its end say what went wrong. This is the full text for a database whose owner is gone:

Msg 22830, Level 16, State 1, Server mssql, Procedure sys.sp_cdc_enable_db_internal, Line 281
Could not update the metadata that indicates database lab_owner is enabled for Change Data Capture. The failure occurred when executing the command 'SetCDCTracked(Value = 1)'. The error returned was 15517: 'Cannot execute as the database principal because the principal "dbo" does not exist, this type of principal cannot be impersonated, or you do not have permission.'. Use the action and error to determine the cause of the failure and resubmit the request.

On Amazon Relational Database Service (RDS), sys.sp_cdc_enable_db gave Msg 22902 to the master user, who is not a sysadmin there. On Azure SQL Database below the S3 service objective it gave Msg 22830 with the inner error 22871. Both are under Managed services and other tools.

One difference between the versions is harmless. When a table is enabled with @supports_net_changes = 1, SQL Server 2022 also prints Update mask evaluation will be disabled in net_changes_function because the CLR configuration option is disabled. and 2019 does not.

Not reproduced: error 15404. Msg 22830 is also reported with inner error 15404, which is about a Windows account that the server cannot look up (Stack Overflow question). A Linux container has no domain to fail against: CREATE LOGIN [CORP\dbadmin] FROM WINDOWS returned Msg 15401, and a database owned by the built-in NT AUTHORITY\NETWORK SERVICE login enabled without error.

Why a change table stays empty​

CDC does not write to a change table when a row changes. A capture job reads the transaction log afterwards and copies each change into the change table. A second job, the clean-up job, deletes old rows.

Both are SQL Server Agent jobs. Microsoft's CDC overview says: "The jobs are created when the first table of the database is enabled for change data capture." In the run they were named cdc.cdclab_capture and cdc.cdclab_cleanup.

Creating a job does not need a running Agent, and running it does. On Linux and in containers the Agent is off unless you turn it on: the environment variable reference says under MSSQL_AGENT_ENABLED, "By default, the agent is disabled."

Three other things give the same symptom.

  • The capture job is stopped while the Agent runs. In the run the change table stayed at 7 rows for 12 seconds after an insert, and went to 8 once the job was started.
  • The rows are older than CDC. Only changes made after the table was enabled are captured. The 4 orders that existed before never appeared in the change table.
  • You are reading the wrong capture instance. A table can have two, each with its own change table.
Versions on this page

The runs used SQL Server 2022 (RTM-CU27-GDR) 16.0.4305.5 and SQL Server 2019 (RTM-CU32-GDR) 15.0.4510.2, Developer Edition on Linux, in containers. Both gave the same result in every step. Output with no version named is from SQL Server 2022. The managed services and other tools were run separately on 23 November 2026, with the versions given at the end of the page.

Enable CDC step by step​

1. Enable the database. The caller must be in sysadmin, and the database owner must be a login that exists.

sql
USE cdclab;
SELECT name, is_cdc_enabled, SUSER_SNAME(owner_sid) AS owner FROM sys.databases WHERE name = N'cdclab';
EXEC sys.sp_cdc_enable_db;

In the run this created a database user named cdc, a schema named cdc, and five tables in it: captured_columns, change_tables, ddl_history, index_columns and lsn_time_mapping. It created no job yet.

2. Enable each table. The caller must be in db_owner.

sql
EXEC sys.sp_cdc_enable_table
@source_schema = N'dbo', @source_name = N'orders',
@role_name = NULL, @supports_net_changes = 1;

@role_name = NULL means no extra role is needed to read the change data. @supports_net_changes = 1 needs a primary key or a unique index, and a table without one must use 0. With no @capture_instance, the capture instance is named dbo_orders and its change table cdc.dbo_orders_CT.

3. Check what exists.

sql
SELECT s.name + N'.' + t.name AS table_name, t.is_tracked_by_cdc
FROM sys.tables t JOIN sys.schemas s ON s.schema_id = t.schema_id
WHERE s.name = N'dbo' AND t.is_ms_shipped = 0;
SELECT capture_instance, supports_net_changes, start_lsn FROM cdc.change_tables;
EXEC sys.sp_cdc_help_jobs;

msdb.dbo.cdc_jobs, the table behind the last call, is created with the first job. Before any table was enabled, a query on it returned Msg 208, Invalid object name 'msdb.dbo.cdc_jobs'.

4. Check that the Agent is running, with the query from the short answer.

5. Change a row and look. With the Agent running, an insert was in the change table within 10 seconds in the run. The capture job polls every 5 seconds by default. These were the first five rows of the change table:

__$start_lsn|__$operation|id|customer_id|quantity
0x0000002C000006200005|2|5|1|5
0x0000002C000006200005|2|6|2|6
0x0000002C000006280003|3|1|1|1
0x0000002C000006280003|4|1|1|11
0x0000002C000006300004|1|4|4|1

Those five rows are two inserts (operation 2), one update as its before and after image (3 and 4), and one delete (1).

To turn CDC off, sys.sp_cdc_disable_table removes one capture instance and sys.sp_cdc_disable_db removes everything. After the second call the run showed is_cdc_enabled 0, no cdc schema and no CDC jobs.

Confirm the diagnosis​

Run these in the database. The comments show what the run returned with the Agent off.

sql
SELECT COUNT(*) AS rows_in_change_table FROM cdc.dbo_orders_CT; -- 0
SELECT sys.fn_cdc_get_max_lsn() AS max_lsn; -- NULL
SELECT COUNT(*) AS log_scan_sessions FROM sys.dm_cdc_log_scan_sessions; -- 0
SELECT COUNT(*) AS cdc_errors FROM sys.dm_cdc_errors; -- 0
SELECT servicename, status_desc, startup_type_desc FROM sys.dm_server_services;
SELECT COUNT(*) AS agent_sessions FROM sys.dm_exec_sessions WHERE program_name LIKE N'SQLAgent%'; -- 0
servicename|status_desc|startup_type_desc
SQL Server Agent (MSSQLSERVER)|Stopped|Automatic

On SQL Server 2019 the same view listed a second row, SQL Server (MSSQLSERVER)|Stopped|Disabled, so read the Agent row. With the Agent running the run showed Running and 4 Agent sessions.

The jobs existed and had never run: start_execution_date was NULL for both in msdb.dbo.sysjobactivity. sys.dm_cdc_errors was empty too, because nothing had failed.

The transaction log tells the same story. After a CHECKPOINT, log_reuse_wait_desc in sys.databases was REPLICATION, which means the log cannot be reused past changes that capture has not read. It went back to NOTHING once the Agent ran.

Issue 1: Enabling CDC fails​

Each fix below was run on both versions, and the enable call succeeded afterwards.

  • Msg 22901. Enable the database before the table.
  • Msg 22902 and 22904. Have a sysadmin enable the database. A db_owner can then enable tables. On Amazon RDS the master user is not a sysadmin, and the database is enabled with msdb.dbo.rds_cdc_enable_db.
  • Msg 22906. Drop or rename the schema or user named cdc. In the run, DROP SCHEMA cdc was enough.
  • Msg 22939. Use @supports_net_changes = 0, or give the table a primary key first.

Msg 22830 with 15517 means the database has no usable owner. It happened after a database was backed up, its owner's login dropped, and the database restored. sys.databases then showed sa as owner, while the login behind dbo inside the database was NULL:

sql
SELECT name, SUSER_SNAME(sid) AS login_behind_dbo FROM sys.database_principals WHERE name = N'dbo';
ALTER AUTHORIZATION ON DATABASE::lab_owner TO sa;
EXEC sys.sp_cdc_enable_db;

After ALTER AUTHORIZATION the same query returned sa, and CDC enabled.

Msg 22830 with 229 came from a database trigger on DDL statements that inserted into an audit table in master. Enabling CDC creates the cdc user, the trigger fired, and the insert into master was denied.

Microsoft's known issues page gives the fix that worked: "Disable any CREATE OBJECT triggers before enabling CDC on a database. Reenable these triggers after CDC is configured."

sql
DISABLE TRIGGER lab_audit_ddl ON DATABASE;
EXEC sys.sp_cdc_enable_db;
ENABLE TRIGGER lab_audit_ddl ON DATABASE;

Issue 2: The change table stays empty​

Both enable calls succeeded, and the change table has no rows. Start SQL Server Agent. In a container, set MSSQL_AGENT_ENABLED=true and create the container again over the same data volume, which is what the lab did:

yaml
environment:
ACCEPT_EULA: "Y"
MSSQL_AGENT_ENABLED: "true"

On a Linux host installed from packages, Microsoft's Agent set-up page gives sudo /opt/mssql/bin/mssql-conf set sqlagent.enabled true followed by a restart of the service. That path was not run here.

In the run, 4 rows were changed while the Agent was off, and one more later. After the Agent started, the capture job's start_execution_date was set, the row that had been waiting was captured, and a new insert arrived within 10 seconds. Nothing had to be enabled again.

AfterRows in cdc.dbo_orders_CT
4 changes with the Agent stopped0, and sys.fn_cdc_get_max_lsn() is NULL
One manual sys.sp_cdc_scan (see below)5: two inserts, an update as two rows, and a delete
One more insert, the Agent still stopped5
The Agent started6: the waiting insert is captured
A new insert7, within 10 seconds

On Amazon RDS the Agent was running and the master user could not stop it, and Azure SQL Database has no Agent at all. On RDS the next cause is the one to check.

If the Agent is running and the table is still empty, the capture job may be stopped:

sql
EXEC sys.sp_cdc_start_job @job_type = N'capture';

With the Agent stopped, that call only prints the same SQLServerAgent is not currently running line.

A test without the Agent. One manual scan shows whether the changes are in the log:

sql
EXEC sys.sp_cdc_scan @maxtrans = 500, @maxscans = 10, @continuous = 0;

In the run it wrote the 5 waiting change rows with the Agent off. It is a test, not a set-up: the next insert stayed uncaptured until the Agent ran.

Issue 3: Msg 313 when reading changes​

cdc.fn_cdc_get_all_changes_<capture_instance> takes a low and a high LSN. Both must lie between the minimum LSN of the capture instance and the maximum LSN of the database:

sql
SELECT sys.fn_cdc_get_min_lsn(N'dbo_orders') AS min_lsn, sys.fn_cdc_get_max_lsn() AS max_lsn;

Anything outside that range fails with a message about arguments, not about a range:

Msg 313, Level 16, State 3, Server mssql, Line 3
An insufficient number of arguments were supplied for the procedure or function cdc.fn_cdc_get_all_changes_ ... .

Five calls produced it in the run.

  • The low end was below the minimum, here 0x00000000000000000000.
  • The high end was above the maximum.
  • One end was NULL. sys.fn_cdc_get_max_lsn() is NULL until the capture job has run once.
  • The low end was above the high end.
  • The row filter was not one the function knows (N'everything' in place of N'all').

A wrong capture instance name leads to the first case. sys.fn_cdc_get_min_lsn(N'dbo.orders'), with a dot where the name has an underscore, returned 0x00000000000000000000 and no error. Microsoft documents that for an instance that "does not exist".

The range moves when clean-up runs​

A reader that saves its position and comes back later can find that position below the minimum. In the run a reader saved 0x0000002C00000C500004. Two changes followed, then a third 70 seconds later, and the clean-up job ran with a retention of 1 minute.

The change table went from 11 rows to 3, and the minimum LSN moved to 0x0000002C00000CB80003. The reader's next call started at 0x0000002C00000C500005, below the new minimum, and failed with Msg 313. The first of the two changes was gone from the change table for good.

Before clean-upAfter clean-up
Rows in cdc.dbo_orders_CT113
Minimum LSN of dbo_orders0x0000002A00000C3800470x0000002C00000CB80003
The reader's next start, 0x0000002C00000C500005Inside the rangeBelow the minimum: Msg 313

Check before every call, and treat a position below the minimum as lost history:

sql
DECLARE @saved BINARY(10) = (SELECT last_lsn FROM dbo.reader_position WHERE reader = N'lab');
DECLARE @min BINARY(10) = sys.fn_cdc_get_min_lsn(N'dbo_orders'), @max BINARY(10) = sys.fn_cdc_get_max_lsn();
DECLARE @from BINARY(10) = CASE WHEN @saved IS NULL THEN @min ELSE sys.fn_cdc_increment_lsn(@saved) END;
IF @max IS NULL
PRINT 'No maximum LSN yet: the capture job has never run.';
ELSE IF @from < @min
PRINT 'The saved position is older than the minimum LSN: changes were cleaned up. Reload the table.';
ELSE IF @from > @max
PRINT 'Nothing new since the saved position.';
ELSE
SELECT * FROM cdc.fn_cdc_get_all_changes_dbo_orders(@from, @max, N'all');

The recovery in the run was to read the 10 rows of the source table again and save the current maximum LSN as the new position. The next change was then read normally.

Issue 4: Schema evolution needs a new capture instance​

A change table has a fixed set of columns. In the run a column named note was added to dbo.orders and a row was written with it. The change table still had its 4 original columns, and the change row carried no note.

SQL Server records the statement in cdc.ddl_history and does nothing else. To capture the column, create a second capture instance under a new name:

sql
EXEC sys.sp_cdc_enable_table
@source_schema = N'dbo', @source_name = N'orders',
@role_name = NULL, @supports_net_changes = 1,
@capture_instance = N'dbo_orders_v2';

Both instances then capture every change, each with its own columns. Move every reader to cdc.dbo_orders_v2_CT, then drop the old instance:

sql
EXEC sys.sp_cdc_disable_table
@source_schema = N'dbo', @source_name = N'orders', @capture_instance = N'dbo_orders';

What each change to dbo.orders did to the change tables in the run:

ChangeChange table afterwardsRows written afterwards
ADD note NVARCHAR(50)dbo_orders_CT keeps its 4 columnsCaptured without note
A second capture instance, dbo_orders_v2dbo_orders_v2_CT has noteCaptured with note, from the instance's own start
DROP COLUMN notedbo_orders_v2_CT keeps notenote is NULL
ALTER COLUMN quantity BIGINT NOT NULLquantity becomes bigint in dbo_orders_v2_CTCaptured as bigint

Four results from the run are worth planning for.

  • There is a gap. The row written after the ALTER TABLE and before the new instance is in the old change table without its note, and not in the new one. Its note value reached no change table.
  • An update of the new column alone leaves no trace. In the runs of 23 November 2026, an UPDATE that set only note before the second instance existed put no row in the old change table. A reader gets no event for it, and no error.
  • Two is the limit. A third instance failed with Msg 22962, so drop the old one before the next schema change.
  • Other changes behave differently. After DROP COLUMN note, the change table kept the column and new rows had NULL in it. After ALTER COLUMN quantity BIGINT, the change table column became bigint by itself.

Tools differ in what they do with the second instance. Debezium and Flink CDC switched to it by themselves, AWS Database Migration Service (DMS) did not need it, and Airbyte's documented fix cost it its saved position. The details are under Managed services and other tools.

Prevent it​

Jobs and retention​

EXEC sys.sp_cdc_help_jobs; showed these defaults on both versions.

JobSettings in the runWhen it runs
cdc.cdclab_capturemaxtrans 500, maxscans 10, continuous 1, pollinginterval 5Starts with SQL Server Agent and keeps running
cdc.cdclab_cleanupretention 4320 minutes (3 days), threshold 5000Daily at 02:00

Retention has to be longer than the longest time a reader can be away. It is set in minutes:

sql
EXEC sys.sp_cdc_change_job @job_type = N'cleanup', @retention = 10080; -- 7 days

Microsoft says that a changed setting applies after the job is stopped and started. The clean-up job is idle between its daily runs, so the stop was refused in the run: SQLServerAgent Error: Request to stop job cdc.cdclab_cleanup (from User sa) refused because the job is not currently running. The next start of the job used the new value.

Retention is not measured from the clock. Microsoft's administration page says: "The specified number of minutes is subtracted from the maximum tran_end_time value from the cdc.lsn_time_mapping table to obtain the new low water mark expressed as a datetime value."

In the run, with a 1-minute retention, the newest captured change was committed at 18:06:25. The change committed at 18:05:03 became the new low end and stayed, and the one before it was removed.

Watch for it​

  • Alert when the Agent row in sys.dm_server_services is not Running, and when sys.fn_cdc_get_max_lsn() stops moving on a database that is being written to.
  • Watch log_reuse_wait_desc. REPLICATION for a long time means the log is growing behind a capture job that is not reading.
  • Read sys.dm_cdc_errors, and do not rely on it alone. It was empty in the run even while the change table stayed empty.
  • Create the new capture instance in the same change window as the schema change, to keep the gap short.

Managed services and other tools​

Two managed services and four tools were put through the cases of this page on 23 November 2026. The versions are in the box at the end of the page.

Amazon RDS for SQL Server​

The instance ran SQL Server 2022 Standard Edition, build 16.0.4305.5, which is the build of the lab above. The database is enabled with a different procedure there. The RDS documentation says: "Before you use CDC with your Amazon RDS DB instances, enable it in the database by running msdb.dbo.rds_cdc_enable_db."

EXEC sys.sp_cdc_enable_db;
Msg 22902 ... Caller is not authorized to initiate the requested action. Sysadmin privileges are required.
EXEC msdb.dbo.rds_cdc_enable_db;
Procedure or function 'rds_cdc_enable_db' expects parameter '@db_name', which was not supplied.
EXEC msdb.dbo.rds_cdc_enable_db 'cdclab';
CDC enabled on database cdclab

Tables are enabled with sys.sp_cdc_enable_table as usual. It printed Job 'cdc.cdclab_capture' started successfully., and an inserted row was in the change table 2 seconds later. To turn CDC off again, sys.sp_cdc_disable_db gave Msg 22902 as well, and msdb.dbo.rds_cdc_disable_db 'cdclab' worked.

A stopped Agent is not the cause on RDS. sys.dm_server_services showed it Running, and the master user was denied the procedure that would stop it.

A stopped capture job gave the same symptom: after sys.sp_cdc_stop_job, two inserts stayed out of the change table for the 15 seconds they were watched. One manual sys.sp_cdc_scan captured them, and after sys.sp_cdc_start_job new rows were captured again.

One table that this page mentions cannot be read there. msdb.dbo.cdc_jobs answered Msg 229, The SELECT permission was denied, for the master user too, and sys.sp_cdc_help_jobs returned the job settings.

Azure SQL Database​

Azure SQL Database has no Agent to start. Microsoft's overview for Azure SQL Database says: "In Azure SQL Database, a change data capture scheduler replaces the SQL Server Agent jobs that capture and cleanup change data for the source tables." In the run sys.dm_server_services did not exist (Msg 208), and sys.sp_cdc_enable_table printed nothing about an Agent.

The service objective decides whether CDC can be enabled at all. At S0, sys.sp_cdc_enable_db failed:

Msg 22830 ... The error returned was 22871: 'Change Data Capture is not supported on Free, Basic or Standard tier Single Database (S0,S1,S2) and Database in Elastic pool with max eDTUs < 100 or max vCore < 1. Please upgrade to a higher Service Objective.'

After scaling to S3 the same call worked, for a login that is db_owner and not sysadmin.

The same Microsoft page says: "The CDC capture job runs every 20 seconds, and the cleanup job runs every hour." In the run the scans started 5 seconds apart, and four changed rows were in the change table 5 seconds after their commit.

The hourly clean-up is what moves the minimum LSN under a reader. With the retention set to 1 minute, nothing was removed for 56 minutes. The clean-up then ran one hour after CDC had been enabled on the database, 2 of 21 change rows were left, and the reader's next call failed with Msg 313 as in the lab.

The job procedures differ too:

StatementAzure SQL Database
sys.sp_cdc_stop_job, sys.sp_cdc_start_jobMsg 2812 ... Could not find stored procedure
sys.sp_cdc_help_jobsWorks. Capture: maxtrans 10000, maxscans 100. Clean-up: retention 4320, threshold 4999
sys.sp_cdc_change_job for the retentionAccepted
msdb.dbo.cdc_jobsMsg 40515. The table is cdc.cdc_jobs in the database itself

The schema change went as in the lab: no note column in the old change table, a second capture instance for it, and Msg 22962 for a third.

Debezium​

Debezium 3.7.1.Final ran against SQL Server 2022 (16.0.4305.5). Its documentation says: "The most likely reason for a missing LSN is that the SQL Server Agent is not running."

With the Agent off, the connector and its task stayed RUNNING and the snapshot arrived. A row written afterwards did not, and the task logged one line at ERROR level, once:

No maximum LSN recorded in the database; SQL Server Agent is not running

That is the wording from Debezium 2.0 on. Version 1.9 says No maximum LSN recorded in the database; please ensure that the SQL Server Agent is running (1.9.7 source, 2.0.0 source).

For a new column the same page describes the gap. With an online schema update, "a potential processing gap can occur after you update the schema in the source database, but before you create the new capture instance." The run showed what the gap looks like from the topic:

Written before the second capture instanceEvent
An insert with a noteop=c without a note field
An update that set only the notenone

The task stayed RUNNING and logged nothing about either. Four seconds after dbo_orders_v2 was created, it logged Migrating schema to Capture instance "dbo_orders_v2" and the next insert arrived with its note. The connector was not restarted.

Dropping the old instance while the connector ran was not silent. The task logged Invalid object name 'cdclab.cdc.dbo_orders_CT'. eight times, restarted itself after 10 seconds and went on without losing the row written in between.

AWS DMS​

AWS DMS 3.6.1 read an RDS for SQL Server source. It did not read the change tables. Its task log said TLOG access mode is 'PreferTlog', and a new column needed no second capture instance:

[TARGET_APPLY ]I: Alter table. Action: 3, statement: ALTER TABLE `dms_from_mssql`.`orders` ADD COLUMN `note` VARCHAR(50) CHARACTER SET utf16 (odbc_endpoint_imp.c:7394)

DMS added the column to the target within two seconds of the ALTER TABLE. A row inserted with a note and an update that set only a note were both in the target, while the change table on the source still had its four columns. The schema change fix of this page is not needed for a DMS task.

MS-CDC still has to be on for each table. The ongoing replication page says that on RDS for SQL Server, "AWS DMS needs to use MS-CDC for tables with or without primary keys." A table with a primary key and without sys.sp_cdc_enable_table lost its updates: inserts and deletes arrived, the task stayed running, and the log had one warning:

[SOURCE_CAPTURE ]W: MS-REPLICATION is not enabled for table '[dbo].[items]'. Therefore, UPDATE changes to it will not be captured. If you want UPDATE changes to be captured, either define a Primary Key for the table (if missing) or enable Microsoft CDC instead. (sqlserver_log_utils.c:1312)

The SQL Server source page warns about the log: "SQL Server tlog entries won't be marked for re-use until the MS CDC capture job processes those changes." With the capture job stopped and 60,000 rows written, the log grew from 8 MB to 72 MB and log_reuse_wait_desc read REPLICATION. The target had every row all the same, and the log was free again after the capture job was started and the next log backup had run.

Airbyte​

Airbyte's SQL Server source connector 5.1.5 was run directly, with the Airbyte protocol commands and without the platform around it. Its source page says: "Airbyte recommends retaining at least 7 days of CDC data."

After the column was added, the connector's discovery listed note. The sync then delivered the two new rows with "note": null, although both rows have a note in the source table, and it delivered nothing for the update that set only a note. Nothing in the output marks those values as wrong.

For a new column, its troubleshooting page recommends disabling and enabling CDC on the table again. In the run that replaced the capture instance: the new one had 5 columns, a new start LSN and an empty change table. A change row that no sync had read yet went with the old one, and the next sync failed:

Incumbent CDC state is invalid, reason: Saved offset no longer present on the server, please reset the connection. To prevent this, increase transaction log retention and/or increase sync frequency. Saved LSN '0000002b:00000b10:0003' is no longer available in SQL Server transaction logs.

That is the default, Fail sync, of the setting Invalid CDC Position Behavior (Advanced). With Re-sync data, one sync ended with Triggering reset and the next read every row of the table again, this time with the notes.

Flink CDC 3.7.0 ran on Flink 2.2.1, and its SQL Server connector carries Debezium 1.9.8.Final. The connector page lists the prerequisite: "The SQL Server Agent is running."

With the Agent off, the job gave no sign of it in its status. It was RUNNING at every reading for 100 seconds with 0 restarts, it printed the snapshot, and an insert made meanwhile never arrived. The TaskManager log had 223 warnings with the Debezium 1.9 wording, No maximum LSN recorded in the database; please ensure that the SQL Server Agent is running.

A new column needs a new job, because the columns are declared in the table definition. The job that did not declare note kept running with its four columns and logged nothing. A job that declared it printed NULL for a row read through the old change table, and switched by itself once the second capture instance existed, with the same Migrating schema to Capture instance "dbo_orders_v2" line as Debezium.

How OLake Go handles this

OLake Go reads the same change tables, so it has the same limits. Its SQL Server connector needs CDC enabled on the database and on each table, and its connection check looks for the capture job.

The connector's documentation says that change tables keep 3 days by default, and that if events expire before they are processed "a full backfill is required to restore consistency". It supports SQL Server 2017 or higher.

For schema changes it switches to a second capture instance once one exists. With Manage Capture Instance turned on it creates that instance itself, which needs db_owner for its user.

References​