Rediger

sys.dm_change_feed_errors (Transact-SQL)

Applies to: SQL Server 2022 (16.x) and later versions Azure SQL Database Azure SQL Managed Instance Azure Synapse Analytics Mirrored databases in Microsoft Fabric SQL database in Microsoft Fabric

Returns recent errors from the change feed, snapshot, or incremental change publish processes.

Use this dynamic management view for:

This view returns rows only when one of the preceding features is configured and has logged an error. Otherwise, the view is empty.

Column name Data type Description
session_id int The session_id maintained by history cache of the log reader.
source_task tinyint Internal change feed task ID.
0 = UNDEFINED
1 = TIMER
2 = CAPTURE
3 = PUBLISH
4 = COMMIT
5 = SNAPSHOT
table_id int The object_id of the relevant table.
table_group_id uniqueidentifier The unique identifier of the table group. It's a GUID generated by the setup flow.
capture_phase_number int Log reader scan phase. If the capture job finishes but the publish or commit job is still in progress, the phase number stays at the last scan (batch processing phase 7). For more information, see batch_processing_phase in sys.dm_change_feed_log_scan_sessions. This column doesn't apply to snapshot.
entry_time datetime The date and time when the error was logged. This value corresponds to the timestamp in the SQL error log. In SQL Server, this time is reported in local time. In Azure SQL Database, the time zone is UTC.
error_number int ID of the error message.
error_severity int Severity level of the message, between 1 and 25.
error_state int State number of the error.
error_message nvarchar(1024) Message text of the error.
batch_start_lsn nvarchar(23) Starting LSN value of the rows being processed when the error occurred.

0 = the error didn't occur within a log scan session.
batch_end_lsn nvarchar(23) End LSN value of the rows being processed when the error occurred.

0 = the error didn't occur within a log scan session.
tran_begin_lsn nvarchar(23) Begin_lsn of the failed transaction. It's NULL for snapshot errors.
tran_commit_lsn nvarchar(23) Commit LSN for the change row in the change data row set on which the failure occurred. It's NULL for snapshot errors.
sequence_value nvarchar(23) LSN value of the rows being processed when the error occurred.

0 = the error didn't occur within a log scan session.
command_id int Command ID from the change row that failed to publish. It's NULL for snapshot errors.

Remarks

This DMV shows up to the 64 most recently logged errors. The DMV might include multiple errors per log scan session, such as retry attempts on landing zone failures (failures writing to the staging storage where the change feed publishes changes). This DMV also shows errors that occur during the snapshot and incremental change publish process.

The list of errors auto-rotates. Newer errors push out earlier entries. Errors that stop occurring remain until newer errors push them out or the list clears completely. The error list is stored in SQL memory, so events such as SQL engine restarts, or disabling change feed, clear it.

Permissions

To query the sys.dm_change_feed_errors dynamic management view, you need VIEW DATABASE STATE or VIEW DATABASE PERFORMANCE STATE permission. For more information about permissions on dynamic management views, see Dynamic Management Views and Functions.

In Fabric SQL database, a user must be granted VIEW DATABASE STATE in the database to query this DMV. Or, a member of any role in the Fabric workspace can query this DMV.

Examples

Use sys.dm_change_feed_errors to check for any recent errors.

SELECT * 
FROM sys.dm_change_feed_errors 
ORDER BY entry_time DESC;