giip
SES Proposal
SQL ServerExpert Review RequiredCDCログファイル障害対応監視

How to Check Whether CDC Log Scanning Has Stopped in SQL Server

Published 2026-08-13 · Updated 2026-08-13 · Last Verified 2026-08-13

Answer

Whether CDC's log scan is running can be checked via `last_commit_time` and `latency` in `sys.dm_cdc_log_scan_sessions`. If the value stays old without updating, the capture job has either stopped or halted on an error. Check the job's state with `sys.sp_cdc_help_jobs`. When capture stops, unread log cannot be released, so `log_reuse_wait_desc` gets stuck on REPLICATION and the log grows.

Applicability of This Document

ProductSQL Server (Enterprise / Standard editions that support CDC) / Amazon RDS for SQL Server
Verified VersionsSQL Server 2008 and later (the editions where CDC is available vary by version — verify)
EnvironmentOn-premises, EC2, Amazon RDS (the CDC enablement procedure differs on RDS)
Required PermissionsReading requires db_owner on the target DB, or VIEW DATABASE STATE for `sys.dm_cdc_log_scan_sessions`. Enabling/disabling CDC and job operations require db_owner (sysadmin depending on the environment)
Execution ImpactThe check commands are read-only. Starting/stopping the job and enabling/disabling CDC are change operations that affect the captured data
RestartNot required
Last Verified2026-08-13

Ready-to-Run Commands

Check which databases have CDC enabled and which tables are capturedRead-only
対象
SQL Server 2008 and later / Amazon RDS for SQL Server
権限
Metadata visibility (`sys.databases` / `sys.tables`)
変更作業
None (read-only)
Production実行
Safe to run
-- 対象: SQL Server 2008 以降 / Amazon RDS for SQL Server
-- 権限: sys.databases / sys.tables のメタデータ可視性
-- 変更作業: なし(参照のみ)
-- Production 実行: 可能
-- CDC が有効なデータベース
SELECT name AS database_name, is_cdc_enabled
FROM sys.databases
WHERE database_id > 4
ORDER BY name;
GO

-- キャプチャ対象テーブル
USE [SampleDB];
GO
SELECT
    s.name  AS schema_name,
    t.name  AS table_name,
    t.is_tracked_by_cdc
FROM sys.tables AS t
INNER JOIN sys.schemas AS s
        ON t.schema_id = s.schema_id
WHERE t.is_tracked_by_cdc = 1
ORDER BY s.name, t.name;

First confirm whether CDC is actually enabled on that database. Since `log_reuse_wait_desc = REPLICATION` can be caused by either CDC or transactional replication, this gives you a starting point for isolating which one is responsible.

State of the log scan session (the central check in this article)Read-only
対象
SQL Server 2008 and later / Amazon RDS for SQL Server
権限
Connection permission to the target DB and VIEW DATABASE STATE
変更作業
None (read-only)
Production実行
Safe to run
-- 対象: SQL Server 2008 以降 / Amazon RDS for SQL Server
-- 権限: 対象DBへの接続権限と VIEW DATABASE STATE
-- 変更作業: なし(参照のみ)
-- Production 実行: 可能
USE [SampleDB];
GO
SELECT
    session_id,            -- 0 はキャプチャジョブ開始以降の集計行
    start_time,
    end_time,
    duration,
    scan_phase,
    error_count,
    start_lsn,
    end_lsn,
    tran_count,
    last_commit_lsn,
    last_commit_time,
    latency,
    empty_scan_count,
    failed_sessions_count
FROM sys.dm_cdc_log_scan_sessions
ORDER BY session_id;

The `session_id = 0` row is a cumulative total since the capture job started. A `last_commit_time` far removed from the current time, a rising `error_count` or `failed_sessions_count`, or a large `latency` are all indicators that the scan is stalled. If the capture job has stopped, this view itself may return no rows (or reset after the job restarts).

How far capture has progressed (LSN-to-time mapping)Read-only
対象
SQL Server 2008 and later / Amazon RDS for SQL Server
権限
Connection permission to the target DB (read permission on the cdc schema)
変更作業
None (read-only)
Production実行
Safe to run
-- 対象: SQL Server 2008 以降 / Amazon RDS for SQL Server
-- 権限: 対象DBへの接続権限(cdc スキーマへの参照権限)
-- 変更作業: なし(参照のみ)
-- Production 実行: 可能
USE [SampleDB];
GO
-- キャプチャ済みの最新トランザクション時刻
SELECT TOP (10)
    start_lsn,
    tran_begin_time,
    tran_end_time,
    tran_id
FROM cdc.lsn_time_mapping
ORDER BY tran_end_time DESC;

-- 現在の最大 LSN と、それに対応する時刻
SELECT
    sys.fn_cdc_get_max_lsn()                            AS max_lsn,
    sys.fn_cdc_map_lsn_to_time(sys.fn_cdc_get_max_lsn()) AS max_lsn_time;

How far the maximum `tran_end_time`, and `sys.fn_cdc_map_lsn_to_time(sys.fn_cdc_get_max_lsn())`, lag behind the current time is the capture delay itself. A lag of a few minutes to tens of minutes can be normal depending on configuration, but if it is stuck for hours, check the job side.

Check the capture instance and the change tableRead-only
対象
SQL Server 2008 and later / Amazon RDS for SQL Server
権限
db_owner on the target DB, or read permission on CDC metadata
変更作業
None (read-only)
Production実行
Safe to run
-- 対象: SQL Server 2008 以降 / Amazon RDS for SQL Server
-- 権限: 対象DBの db_owner または CDC メタデータへの参照権限
-- 変更作業: なし(参照のみ)
-- Production 実行: 可能
USE [SampleDB];
GO
-- キャプチャインスタンスの一覧(対象テーブル・変更テーブル名・キャプチャ列)
EXEC sys.sp_cdc_help_change_data_capture;
GO

-- 変更テーブルに実際に行が入っているか(キャプチャインスタンス名は環境に合わせる)
SELECT TOP (5)
    __$start_lsn,
    __$seqval,
    __$operation,     -- 1:削除 2:挿入 3:更新前 4:更新後
    __$update_mask
FROM cdc.dbo_SampleTable_CT
ORDER BY __$start_lsn DESC;

The change table is named `cdc.<capture instance name>_CT`. The default capture instance name is `<schema name>_<table name>`. If the source table is being updated but no new rows appear in `_CT`, capture is not progressing.

Status of the capture job and cleanup jobRead-only
対象
SQL Server 2008 and later (environments where SQL Agent is available)
権限
db_owner on the target DB, and read permission on msdb
変更作業
None (read-only)
Production実行
Safe to run
-- 対象: SQL Server 2008 以降(SQL Agent が利用できる環境)
-- 権限: 対象DBの db_owner、および msdb への参照権限
-- 変更作業: なし(参照のみ)
-- Production 実行: 可能
USE [SampleDB];
GO
-- CDC ジョブの構成(ポーリング間隔・保持期間など)
EXEC sys.sp_cdc_help_jobs;
GO

-- CDC ジョブの登録内容
SELECT
    job_type,
    database_id,
    maxtrans,
    maxscans,
    continuous,
    pollinginterval,
    retention,
    threshold
FROM msdb.dbo.cdc_jobs;
GO

-- SQL Agent ジョブとしての稼働状況と直近の実行結果
SELECT
    j.name              AS job_name,
    j.enabled,
    h.run_date,
    h.run_time,
    h.run_status,       -- 0:失敗 1:成功 2:再試行 3:取消 4:実行中
    h.message
FROM msdb.dbo.sysjobs AS j
LEFT JOIN msdb.dbo.sysjobhistory AS h
       ON j.job_id = h.job_id
      AND h.step_id = 0        -- ジョブ全体の結果
WHERE j.name LIKE 'cdc.%'
ORDER BY h.run_date DESC, h.run_time DESC;

CDC's jobs are named `cdc.<database name>_capture` and `cdc.<database name>_cleanup` by default. If `enabled = 0` or `run_status = 0` (failure) persists, that is the cause of the stoppage. Environments without SQL Agent use a different job mechanism, so check the configuration of your target environment.

Start the capture job (if it had stopped)Medium
対象
SQL Server 2008 and later / Amazon RDS for SQL Server
権限
db_owner on the target DB (sysadmin depending on the environment)
変更作業
Yes (starts the capture job; reading of unprocessed log begins)
Production実行
Can be run, but expect a spike in I/O right after starting if there is a backlog
-- 対象: SQL Server 2008 以降 / Amazon RDS for SQL Server
-- 権限: 対象DBの db_owner(環境により sysadmin)
-- 変更作業: あり(キャプチャジョブの開始。滞留ログの読み取りが始まる)
-- Production 実行: 可能。滞留量が多い場合は I/O 増を見込むこと
USE [SampleDB];
GO
EXEC sys.sp_cdc_start_job @job_type = N'capture';

-- 停止する場合
-- EXEC sys.sp_cdc_stop_job @job_type = N'capture';

Resuming a capture that has been stopped for a long time reads the entire backlog of accumulated log at once. If the log volume is large, I/O and CPU will spike right after resuming. Avoid business hours, or check the `maxtrans` / `maxscans` settings before doing this.

Disable and reconfigure CDC (requires expert review)Expert Review Required
対象
SQL Server 2008 and later / Amazon RDS for SQL Server
権限
db_owner on the target DB (sysadmin depending on the environment)
変更作業
Yes (deletes the change table and capture configuration; already-captured change history is lost)
Production実行
Not allowed. Requires an impact assessment on downstream systems and a resync plan first
-- 対象: SQL Server 2008 以降 / Amazon RDS for SQL Server
-- 権限: 対象DBの db_owner(環境により sysadmin)
-- 変更作業: あり(キャプチャインスタンスと変更テーブルを削除)
-- Production 実行: 不可。下流システムへの影響評価と再同期計画を先に確定すること
USE [SampleDB];
GO
-- テーブル単位で CDC を無効化する
EXEC sys.sp_cdc_disable_table
     @source_schema   = N'dbo',
     @source_name     = N'SampleTable',
     @capture_instance = N'dbo_SampleTable';

-- データベース全体で CDC を無効化する(すべての変更テーブルが削除される)
-- EXEC sys.sp_cdc_disable_db;

Disabling CDC deletes the change table. Any change history not yet read by downstream systems cannot be recovered. After reconfiguring, downstream systems will need to resync (redo their initial load), so finalize an impact assessment and procedure before doing this. On Amazon RDS, enabling/disabling CDC sometimes uses RDS-specific stored procedures, so check the procedure for your target environment.

How to Read the Results

ColumnMeaningWhat to Check
session_idLog scan session ID (0 is the cumulative row)Use the row where 0 to see the overall trend since the job started
last_commit_timeCommit time of the last captured transactionThe gap from the current time is the delay itself — a stalled value means the scan is stuck
latencyScan delayA continuous increase means processing cannot keep up
error_countNumber of errors in that sessionIf nonzero, check the error details in the SQL Agent job history
failed_sessions_countNumber of failed sessions (cumulative row)An increase means capture has been repeatedly failing
empty_scan_countNumber of scans with no matching transactionsIf this keeps rising despite ongoing updates, check the target configuration
tran_countNumber of transactions processedIf it stays at 0 and does not increase, the scan is running but finding nothing
tran_end_time (cdc.lsn_time_mapping)End time of a captured transactionHow far the maximum value lags behind the current time
run_status (sysjobhistory)Job execution resultIf 0 (failure) persists, check the `message` column for the cause

When to Use This

  • The transaction log keeps growing, and `log_reuse_wait_desc` stays fixed at REPLICATION
  • The source table is being updated, but no new rows appear in `cdc.<capture_instance>_CT`
  • Data reaching a downstream system has stopped as of a certain point in time
  • CDC's capture job keeps failing repeatedly in SQL Agent

Possible Causes (Most Likely First)

  1. 01

    The capture job has stopped

    This happens when SQL Agent is stopped, the job is disabled, or `sys.sp_cdc_stop_job` has been run manually. If the job is not running, the log scan does not progress and unread log is not released.

  2. 02

    The capture job keeps failing with an error

    Schema changes to a captured table, insufficient permissions, or insufficient capacity on the change-table side can cause the job to fail, increasing `error_count` and `failed_sessions_count`. The cause is recorded in the `message` column of the job history.

  3. 03

    CDC metadata is inconsistent after a database restore or attach

    Restoring or attaching a CDC-enabled database to a different instance can leave CDC state or jobs not carried over as expected. Check the restore options used, and whether the jobs exist after the restore.

  4. 04

    Capture capacity cannot keep up with the volume of changes

    A burst of changes from a bulk update, depending on the `maxtrans` / `maxscans` / `pollinginterval` settings, can outpace capture's processing capacity, causing delay to accumulate. In this case the job is running, but `latency` keeps increasing.

  5. 05

    Transactional replication and CDC coexist on the same database

    When transactional replication and CDC are used together on the same database, they share the behavior of the Log Reader. You need to isolate which one is behind `log_reuse_wait_desc = REPLICATION` by checking the state of both.

  6. 06

    The cleanup job is not running, causing the change table to grow

    Even if capture is progressing, if the cleanup job has stopped, the `_CT` table keeps growing past its retention period. This is a different symptom from log bloat, but worth checking at the same time.

Diagnostic Steps

  1. 1

    Check whether CDC is enabled and what is being captured

    Read-only

    Check `sys.databases.is_cdc_enabled` and `sys.tables.is_tracked_by_cdc`.

  2. 2

    Look at the state of the log scan session

    Read-only

    Check `last_commit_time`, `latency`, and `error_count` in `sys.dm_cdc_log_scan_sessions`. This is the most direct indicator.

  3. 3

    Measure the lag in captured time

    Read-only

    Check the gap between the maximum `tran_end_time` in `cdc.lsn_time_mapping` and the current time.

  4. 4

    Check the job's running status and failure details

    Read-only

    Check `sys.sp_cdc_help_jobs` and `msdb.dbo.sysjobs` / `sysjobhistory`, looking at `enabled`, `run_status`, and `message`.

  5. 5

    Cross-check against log-side symptoms

    Read-only

    If `sys.databases.log_reuse_wait_desc` is REPLICATION, CDC being stopped and log bloat are likely the same root cause.

  6. 6

    Check for replication

    Read-only

    Check `is_published` / `is_subscribed` to isolate whether CDC or replication is holding the unread log.

Solutions

Low-risk action that can be done immediately

  • Check SQL Agent and the capture job, and start it

    Medium

    If the job has simply stopped, resuming it via `sys.sp_cdc_start_job` or re-enabling it in SQL Agent restarts capture. Expect an I/O increase if there is a large backlog.

  • Check the error message behind the job failure

    Read-only

    The error detail is recorded in the `message` column of `sysjobhistory`. It is often permissions, a schema change, or capacity — respond based on the specific cause.

  • Free up log-side space first

    Medium

    If the log is nearly exhausted, free up space so writes do not stop before capture resumes. Resolving the root cause still comes first.

Change requiring advance review

  • Tune the capture job's parameters

    Medium

    Adjust `maxtrans`, `maxscans`, and `pollinginterval` via `sys.sp_cdc_change_job` to secure enough processing capacity for the volume of changes. Re-measure the delay trend after changing the settings.

  • Review the cleanup job and retention period

    Medium

    Cross-check the `retention` setting against how long downstream systems take to read the data. Too short a retention period risks deleting unread data.

  • Revisit how bulk updates are executed

    Low

    Splitting large updates into batches can reduce peak capture delay.

  • Add capture delay to your monitoring

    Read-only

    Periodically pull the gap between `last_commit_time` and the current time, and alert when it crosses a threshold. This catches the problem before it manifests as log bloat.

Work requiring expert review

  • Reconfigure CDC (disable and re-enable)

    Expert Review Required

    The change table is deleted and unread change history is lost. This requires downstream systems to resync (redo their initial load), so it assumes an impact assessment and a finalized procedure.

  • Recreate the capture instance for a schema change

    Expert Review Required

    This approach creates a new capture instance and switches to it to keep up with, for example, a new column. You need to manage the downstream read position across the switchover.

!Warnings

  • Disabling CDC (`sys.sp_cdc_disable_table` / `sys.sp_cdc_disable_db`) deletes the change table. Any change history not yet read by downstream systems cannot be recovered.
  • Resuming a capture that has been stopped for a long time reads the entire backlog of log at once, spiking I/O and CPU. Avoid business hours, or throttle the processing volume in stages.
  • `log_reuse_wait_desc = REPLICATION` can occur from either CDC or transactional replication. Do not conclude the cause from CDC alone.
  • A schema change to a captured table can create a mismatch with the capture instance configuration. Decide on a procedure for handling added columns ahead of time.
  • On Amazon RDS for SQL Server, enabling/disabling CDC sometimes has an RDS-specific procedure. Do not apply an on-premises procedure as-is — check the procedure for your target environment.

Differences by Version and Environment

SQL Server 2008 and laterCDC along with `sys.dm_cdc_log_scan_sessions`, `cdc.lsn_time_mapping`, and `sys.sp_cdc_help_jobs` are available. The editions where this is available vary by version, so verify on the target environment.
SQL Server 2016 and laterSome versions include a `__$command_id` column in the change table. Check the column layout from the results of `sys.sp_cdc_help_change_data_capture`.
Amazon RDS for SQL ServerUse the procedure RDS provides for enabling/disabling CDC. The read-only DMVs and catalog views work as usual, but verify handling of SQL Agent jobs and other details on the target environment (verify before relying on this).

If This Doesn't Resolve It

  • The transaction log's `log_reuse_wait_desc`

    If the log is still not released after resuming CDC, check whether another factor (an open transaction, replication) coexists.

  • Size and retention period of the change table (`_CT`)

    Check whether the cleanup job is running and whether the `retention` setting matches the read interval of downstream consumers.

  • Read position of downstream systems

    Check which LSN the consuming side has read up to, and whether it falls within the range CDC retains.

  • Operational status of the SQL Agent service

    Rule out the possibility that the job is not running because the Agent service itself is stopped, rather than a CDC-side problem.

Basis and Limitations of This Document

Explanation based on official product documentation

A general procedure based on the public specifications of SQL Server's CDC-related objects (`sys.dm_cdc_log_scan_sessions`, `cdc.lsn_time_mapping`, `sys.sp_cdc_help_change_data_capture`, `sys.sp_cdc_help_jobs`, `msdb.dbo.cdc_jobs`, `sys.sp_cdc_start_job` / `sys.sp_cdc_disable_table`). Amazon RDS-specific CDC enablement procedures and edition requirements vary by version and service, so this assumes verification on the target environment.

FAQ

Why does the log file grow when CDC stops?

CDC reads the transaction log to extract changes. Log that capture has not yet read cannot be truncated, so when the job stops, log accumulates instead of being released. You can confirm this state by seeing `log_reuse_wait_desc` in `sys.databases` become REPLICATION.

Can this be run in production?

All the check queries (`sys.dm_cdc_log_scan_sessions`, `cdc.lsn_time_mapping`, `sys.sp_cdc_help_jobs`, and job history lookups) are read-only and can be run in production. Starting the capture job is a change operation, and disabling/reconfiguring CDC is a high-risk operation that affects downstream systems.

Does this work on AWS RDS?

The read-only DMVs and catalog views work on Amazon RDS for SQL Server as well. However, enabling/disabling CDC sometimes has an RDS-specific procedure, and handling of SQL Agent jobs also varies by environment. Always check the procedure for your target environment.

What permissions are required?

Reading `sys.dm_cdc_log_scan_sessions` requires connection permission to the target DB and VIEW DATABASE STATE; running CDC stored procedures like `sys.sp_cdc_help_jobs` requires db_owner on the target DB. Starting/stopping jobs or enabling/disabling CDC may require sysadmin depending on the environment.

How should I interpret the results?

If `last_commit_time` stays far from the current time without updating, `error_count` or `failed_sessions_count` is increasing, or the latest `tran_end_time` in `cdc.lsn_time_mapping` is old — any of these means the scan is not progressing. Next, check `enabled` and `run_status` on the job side.

Does disabling CDC solve the problem?

Log bloat stops, but the change table is deleted and unread change history is lost. Downstream systems will need to resync, so disabling CDC is a last resort to be taken only after finalizing an impact assessment and a resync plan.

Questions This Document Covers

  • I want to check whether CDC capture is running
  • log_reuse_wait_desc is not changing from REPLICATION
  • I want to know why no data is appearing in CDC's _CT table

What the Risk Labels Mean

  • Read-onlyDoes not change data or settings.
  • LowImpact is limited, but permissions and load should be checked.
  • MediumMay affect performance, locking, or cost.
  • HighMay cause an outage, data loss, or require recovery work.
  • Expert Review RequiredRequires a separate review before applying to production.

GIIP's Scope of Support

CDC stopping does not raise any error at the moment it happens. It typically only surfaces hours later, once the log file has ballooned and writes start failing. At GIIP, we pull the `last_commit_time` lag and the log's `log_reuse_wait_desc` together, and when both move in the same direction, we notify the person in charge with the cause already tied together. Operations that touch data consistency, like resuming capture, are excluded from automatic execution — only detection and cause isolation are automated.

Author & Technical Review

GIIP Production Operations Team

About 30 years of experience in designing, migrating, and operating large-scale web services, SQL Server, Oracle, AWS, and Azure. Experience includes 12 sets of x12large-class AWS RDS for SQL Server environments, an Oracle environment with roughly 120,000 tables, and migrating roughly 3TB from TiDB to Aurora MySQL. AI agents and human experts currently continue to monitor and operate multiple cloud databases and about 30 web services.

Related Knowledge

Related Services

Request an investigation of log bloat caused by stopped CDC

If you need to repeat the same checks across multiple environments, we can discuss your entire operations setup.

Request an investigation of log bloat caused by stopped CDC

← Back to Knowledge Base