---
title: "CDC Sink: Troubleshooting"
description: "Covers common problems encountered when running CDC Sink tasks and how to resolve them, including startup failures, error states, and missing documents."
url: "https://docs.ravendb.net/7.2/server/ongoing-tasks/cdc-sink/troubleshooting"
version: "7.2"
---

# CDC Sink: Troubleshooting

> RavenDB publishes an official agent skill for coding assistants at https://docs.ravendb.net/skills/ravendb/SKILL.md (also installable with `npx skills add ravendb/skills`). The skill describes itself as: "Read this before writing any RavenDB query, client call or /databases/ request. Covers server setup, document modelling, the Node.js, .NET and Python clients, RQL, indexes, vector search and AI agents. Code written from recall tends to run and return the wrong rows, because RQL resembles SQL and the clients take field names as plain strings."

> **Note**
>
> - Use this article to diagnose common CDC Sink task problems and find the relevant recovery steps.
>
> - In this article:
>   - [Table verification fails or returns warnings](#table-verification-fails-or-returns-warnings)
>   - [Task fails to start](#task-fails-to-start)
>   - [Task enters error state](#task-enters-error-state)
>   - [Documents not appearing](#documents-not-appearing)
>   - [Embedded items missing or incorrect](#embedded-items-missing-or-incorrect)
>   - [DELETE not applied](#delete-not-applied)
>   - [Patch errors](#patch-errors)
>   - [Source schema changes](#source-schema-changes)
>   - [Partial export/import and state loss](#partial-export-import-and-state-loss)
>   - [Shared replication slot across databases](#shared-replication-slot-across-databases)

## Table verification fails or returns warnings {#table-verification-fails-or-returns-warnings}

**Symptom**:

[**Verify tables**](https://docs.ravendb.net/7.2/server/ongoing-tasks/cdc-sink/manage-cdc-sink-tasks/create-task.md#verify-tables) in Studio shows **Verification failed** or **Tables verified with warnings**,  
or Studio asks you to confirm with **Save anyway** when you save the task.  
When using the [dry-run REST endpoint](https://docs.ravendb.net/7.2/server/ongoing-tasks/cdc-sink/manage-cdc-sink-tasks/create-task.md#verify-the-configuration), the response has `Success: false` or a non-empty `Warnings` list.

**Verification failed**:

Verification stopped at an error. The task may encounter the same problem when it starts.  
A verification failure can also be transient or specific to the node that ran verification.  
Verification stops at the first error, so after fixing it, verify again to check for further errors.

**Common causes**:

- **Source database unreachable**  
  The RavenDB node Studio is connected to cannot reach the source database, or the credentials are wrong.
- **Missing permissions**  
  Errors about setting up CDC objects on the source include the command an administrator can run instead.  
  For PostgreSQL, see [Check permissions with Verify tables](https://docs.ravendb.net/7.2/server/ongoing-tasks/cdc-sink/source-database-setup/postgres/permissions-and-roles.md#check-permissions-with-verify-tables).
- **Source database not configured for CDC**  
  For example, PostgreSQL `wal_level` is not `logical`, or MySQL `binlog_format` is not `ROW`.
- **Missing table or column**  
  A configured source table or mapped column does not exist in the source database.
- **Timeout**  
  Verification timed out while checking the source database (*"CDC verification timed out."*).
- **Request failed**  
  The verification request itself failed (*"The dry run request failed. Check the Notification Center for details."*).  
  Check the [Notification Center](https://docs.ravendb.net/7.2/monitoring/alerts-and-notifications/notification-center.md) for the reason.

**Tables verified with warnings**:

Verification completed, but reported conditions the task may run into, or will handle itself, when it starts.  
Warnings do not prevent saving the task.

- **PostgreSQL: publication does not include all tables**  
  *"Publication '\<name>' does not include tables: ..."*  
  Verification does not change the publication.  
  When the task starts, it adds the missing tables to the publication.  
  This requires ownership of the publication and the tables being added.  
  Otherwise, a database administrator must add them with `ALTER PUBLICATION ... ADD TABLE`.

- **PostgreSQL: embedded table needs REPLICA IDENTITY FULL**  
  *"Insufficient permissions to set REPLICA IDENTITY FULL on '\<table>'..."*  
  Verification does not attempt this change, so the warning is reported whether or not the user has permission to make it.
  It means that when the task starts, it runs `ALTER TABLE ... REPLICA IDENTITY FULL` on this table, which requires ownership of the table.
  Only the first embedded table that needs the change is reported.  
  Learn more in [REPLICA IDENTITY](https://docs.ravendb.net/7.2/server/ongoing-tasks/cdc-sink/source-database-setup/postgres/replica-identity.md).

- **Source cleanup failed**  
  *"source cleanup failed: ..."*  
  Verification could not remove CDC objects it created on the source database, see below.

**Tables verified**:

Verification completed without an error.  
This does not mean the tables contain rows: empty tables also pass.  
Some conditions are checked only when the task starts reading changes, for example:

- SQL Server: whether the SQL Server Agent is running.
- MySQL/MariaDB: whether binary logging is enabled, and whether the user has the replication privileges.

**Objects left on the source database after a cleanup failure**:

When verification completes, it attempts to remove the CDC objects it created.  
It allows up to 30 seconds for the cleanup, including after a verification timeout.  
If the cleanup fails, objects may remain on the source database:

- **PostgreSQL** - a publication that verification created.  
  The replication slot that verification creates is temporary, so PostgreSQL drops it automatically.
- **SQL Server** - CDC enabled on the database or on configured tables.
- **MySQL/MariaDB** - nothing, verification creates nothing on the source database.

A leftover PostgreSQL publication does not retain WAL.  
If it has the name configured for the task, the task uses it when it starts.  
When no publication name is configured, verification uses `rvn_cdc_p_<32 hex characters>`,  
while a saved task uses `rvn_cdc_p_<numeric task ID>`.  
The query below lists both. Drop a leftover publication only after confirming that no task uses it.

```sql
-- List publications with the CDC Sink prefix (includes publications used by tasks)
SELECT pubname FROM pg_publication WHERE pubname LIKE 'rvn_cdc_p_%';

-- Drop the publication left by verification (one that no task uses)
DROP PUBLICATION IF EXISTS "rvn_cdc_p_<id>";
```

Before disabling SQL Server CDC that verification left enabled,  
make sure no CDC Sink task or other application relies on CDC for that database or table.

```sql
-- If CDC was not enabled on the database before verification
EXEC sys.sp_cdc_disable_db;

-- Otherwise, for each table that verification enabled
EXEC sys.sp_cdc_disable_table
    @source_schema = N'dbo',
    @source_name = N'orders',
    @capture_instance = N'all';
```

## Task fails to start {#task-fails-to-start}

**Symptom**:  
Task remains in `Error` state immediately after creation.

**Common causes**:

- **Invalid connection string**  
  Verify that the connection string name matches a SQL connection string defined for the database.

- **Connection refused**  
  The source database is unreachable from the RavenDB server. Verify host, port, and firewall rules.

- **Authentication failure**  
  The credentials in the connection string are incorrect or the source-database user does not have the required permissions.
  For PostgreSQL, see [Permissions and Roles](https://docs.ravendb.net/7.2/server/ongoing-tasks/cdc-sink/source-database-setup/postgres/permissions-and-roles.md).

- **PostgreSQL WAL level not set to `logical`**  
  CDC Sink requires logical replication enabled on the PostgreSQL source.
  See [WAL Configuration](https://docs.ravendb.net/7.2/server/ongoing-tasks/cdc-sink/source-database-setup/postgres/wal-configuration.md).

Check the error message in the [Notification Center](https://docs.ravendb.net/7.2/monitoring/alerts-and-notifications/notification-center.md) (bell icon in Studio) for the specific failure reason.

To catch most of these problems before the task is saved, use **Verify tables**,
see [Table verification fails or returns warnings](#table-verification-fails-or-returns-warnings).

## Task enters error state {#task-enters-error-state}

**Symptom**:  
Task was running, then stopped with an error.

**Common causes**:

- **PostgreSQL replication slot issue**  
  Verify that the configured slot exists and uses the `pgoutput` plugin.

  If a slot with the task's configured name already exists but uses a different plugin,
  CDC Sink fails to start with an error such as
  *"Replication slot '\<name>' exists but uses plugin '\<plugin>' instead of 'pgoutput'"*.  
  Drop the conflicting slot so CDC Sink can recreate it with `pgoutput`
  (see [Dropping a replication slot](https://docs.ravendb.net/7.2/server/ongoing-tasks/cdc-sink/source-database-setup/postgres/cleanup-and-maintenance.md#dropping-a-replication-slot)).  
  To use a different slot name, delete the task and create a new one with a distinct `SlotName`.

  If the slot was dropped and recreated, CDC Sink may detect that the slot starts after the task's saved LSN;  
  changes in that gap cannot be recovered from the slot.

- **Source table schema changed**  
  Mapped column changes, renamed columns, or SQL Server CDC schema changes can make the task enter fallback mode or require configuration/source-side updates.
  See [Source Schema Changes](https://docs.ravendb.net/7.2/server/ongoing-tasks/cdc-sink/source-schema-changes.md).

- **PostgreSQL replication lag too large**  
  If CDC Sink falls behind, the PostgreSQL replication slot can retain WAL segments and consume disk space.  
  Check slot lag and relevant PostgreSQL WAL-retention settings, such as `max_slot_wal_keep_size`.

- **Persistent connection failure**  
  The source has been unreachable through multiple retry cycles. The first fallback delay is 5 seconds;
  subsequent retry delays roughly double up to the `CdcSink.MaxFallbackTimeInSec` base cap (default 15 minutes), with small jitter.
  Restore connectivity and the task resumes automatically on the next retry.

## Documents not appearing {#documents-not-appearing}

**Symptom**:  
SQL rows exist but corresponding RavenDB documents are not created.

**Check**:

1. **Initial load still running**  
   CDC Sink scans configured tables before it starts streaming captured changes.  
   For large tables, rows that have not been scanned yet will not appear. Check the task progress in Studio.

2. **`SkipInitialLoad = true`**  
   If the task was created with `SkipInitialLoad`, existing source rows are not scanned.  
   They appear only if they were already loaded into RavenDB or are later changed in the source database.

3. **Task or table is disabled**  
   Verify the task state is `Enabled` or `PartiallyEnabled`, not `Disabled`,  
   and that the table's `Disabled` flag is not set to `true`.

4. **Primary-key columns are wrong**  
   `PrimaryKeyColumns` are used to build the RavenDB document ID.  
   Verify they name source columns that exist, uniquely identify the row, and are included in `Columns`.

5. **Expected columns are not mapped**  
   Only columns listed in `Columns` are written as document properties.  
   Add mappings for any source columns that should appear in the document.

## Embedded items missing or incorrect {#embedded-items-missing-or-incorrect}

**Symptom**:  
Parent document exists but embedded array/map is empty or items are missing.

**Check**:

1. **`JoinColumns` mismatch**  
   `JoinColumns` must contain the embedded table columns whose values identify the direct parent row.  
   CDC Sink pairs them with the parent's `PrimaryKeyColumns` by position, so the count and order must match.

2. **Embedded `PrimaryKeyColumns` are wrong**  
   For `Array` and `Map` embedded tables, these columns identify the item inside the parent's array or map.
   If they are incomplete or wrong, UPDATE events can create duplicates and DELETE events may not find the item to remove.

3. **DELETE event missing routing columns**
   For PostgreSQL embedded table deletes, CDC Sink needs the old row values for both the join columns and the embedded item's primary-key columns.
   If the join columns are not part of the table's primary key, configure `REPLICA IDENTITY` so DELETE events include them.
   See [REPLICA IDENTITY](https://docs.ravendb.net/7.2/server/ongoing-tasks/cdc-sink/source-database-setup/postgres/replica-identity.md).

4. **Embedded `Type` changed after data was written**  
   `Type` controls whether embedded data is stored as an `Array`, `Map`, or `Value`.
   If you change it after documents already exist, migrate or re-process existing documents so the property has a consistent shape.

## DELETE not applied {#delete-not-applied}

**Symptom**:  
A source row was deleted, but the RavenDB document or embedded item still exists.

**Check**:

1. **`OnDelete.IgnoreDeletes = true`**  
   When this flag is set, CDC Sink skips the automatic document delete or embedded-item removal.  
   If `OnDelete.Patch` is also configured, the patch still runs, but the item is kept unless the script removes it explicitly.

2. **PostgreSQL DELETE event missing routing columns (embedded tables)**  
   For embedded table deletes, CDC Sink needs old row values that identify the parent document and the embedded item.
   If those columns are not covered by the table's primary key or configured `REPLICA IDENTITY`,  
   the DELETE event may not contain enough data to route the delete.
   See [REPLICA IDENTITY](https://docs.ravendb.net/7.2/server/ongoing-tasks/cdc-sink/source-database-setup/postgres/replica-identity.md).

3. **Delete patch keeps the data intentionally**  
   Review `OnDelete.Patch` for archive or soft-delete logic, such as setting an `Archived` flag instead of deleting the document or embedded item.

## Patch errors {#patch-errors}

**Symptom**:  
Task enters error state with a message referencing a JavaScript patch failure.

**Check**:

1. **Script syntax or runtime error**  
   Test the script with the CDC Sink task's **Test** tool.
   The test runs CDC Sink mapping and the relevant `Patch` or `OnDelete.Patch` against source rows without saving documents.

2. **Missing values in the patch context**  
   `$old` can be `null` for new documents/items, and DELETE events may not include every source column in `$row`.  
   Use optional chaining and nullish coalescing, for example: `$old?.Amount ?? 0`.

3. **`load()` returns `null`**  
   A document loaded with `load(id)` may not exist yet.  
   Guard the result before reading from it:

```javascript
const related = load("Collection/123");
if (related) {
    this.RelatedName = related.Name;
}
```

4. **Step limit exceeded**  
   Patch scripts have a step quota controlled by `Patching.MaxStepsForScript` (default `10_000`).  
   Long loops, repeated `load()` calls, or large in-script computations can exceed it.  
   See the [configuration reference](https://docs.ravendb.net/7.2/server/configuration/patching-configuration.md) for this setting.

## Source schema changes {#source-schema-changes}

- Adding, removing, renaming, or retyping columns in source tables can affect CDC Sink differently depending on the database engine.

- PostgreSQL handles many changes transparently, MySQL can detect many changes but has positional and type-code limitations,
  and SQL Server requires an explicit capture-instance procedure for schema changes.

- See [Source Schema Changes](https://docs.ravendb.net/7.2/server/ongoing-tasks/cdc-sink/source-schema-changes.md) for the full guide,
  including per-engine behavior, examples, recovery steps, and the SQL Server procedure.

## Partial export/import and state loss {#partial-export-import-and-state-loss}

**Symptom**:  
After importing a database export, CDC Sink re-reads all data from the source database from the beginning,  
performing a full initial load even though the task configuration is present and the data already exists in RavenDB.

**Cause**:

CDC Sink stores two separate pieces of information:

- **Task configuration**  
  Stored in the cluster-wide **database record**.  
  It is included by default when the `CdcSinks` database-record item is exported/imported.
- **Processing state**  
  Stored as a document named `@cdc-states/<task name>` in the `@cdc-states` system collection.  
  This tracks the last processed source-database change position (`LastLsn`) and per-table initial-load progress.

If you export/import the task configuration but skip documents, skip system documents, or exclude the `@cdc-states` collection,
the task configuration is restored but the processing state document is missing.

When CDC Sink starts with a valid configuration and no matching state document, it starts fresh:  
it captures a new source checkpoint, performs a full initial load of the configured enabled tables,  
and then streams changes from that checkpoint.

For large source databases,  
the new initial load can take significant time and place heavy load on both the source database and RavenDB.

**How to avoid this:**

- Include documents in the export/import, including the `@cdc-states` collection.
- If using Smuggler or the REST API for selective export/import,  
  make sure system documents are included and the `@cdc-states` collection is not filtered out.
- Imported tasks are disabled by default.  
  Before enabling the task, verify that the matching `@cdc-states/<task name>` document was imported.
- If the state document is missing but the target RavenDB data is already up to date,
  set `SkipInitialLoad = true` before the task's first start.
  If the task has already started, recreate it with `SkipInitialLoad = true`.

> **Warning**
>
> There is no *supported* way to manually set the last LSN position.
>
> Although the state document in `@cdc-states` can technically be edited, doing so is risky:  
> an incorrect LSN can skip changes, replay changes from the wrong point, or produce inconsistent documents.
>
> If the state document is lost, the safest options are to re-read from the beginning or start with `SkipInitialLoad`
> when you are sure the target data is already up to date.

## Shared replication slot across databases {#shared-replication-slot-across-databases}

**Symptom (PostgreSQL)**:  
After copying a CDC Sink task to a second database (via export/import or backup/restore),  
one of the two tasks sits in fallback mode with an error like:

```text
Process is in error recovery (fallback mode). Last error: <timestamp>. Next retry in: 464s.
```

**Cause**:

Export/import and backup/restore copy the task configuration verbatim,
including the immutable `SlotName` and `PublicationName`.

A PostgreSQL logical replication slot can be consumed by only **one active connection at a time**.
When two enabled CDC Sink tasks point to the same slot,
one task attaches to the slot and the other enters error-recovery (fallback) mode.

While the second task cannot attach, it does not apply new source changes.  
Processing resumes only after that task can connect to the slot on a later retry.

**Resolution:**

- Keep the task **enabled in only one database at a time** when the configuration is shared.  
  For export/import, imported tasks are disabled by default;  
  for restore, use `DisableOngoingTasks` or disable the task on one database before both can run.
- To run the task against **both** databases at once, give each copy its own dedicated slot and publication  
  (set a distinct `SlotName`/`PublicationName` in `CdcSinkPostgresSettings` before enabling the copy).

See [One active consumer per slot](https://docs.ravendb.net/7.2/server/ongoing-tasks/cdc-sink/source-database-setup/postgres/initial-setup.md#one-active-consumer-per-slot).

## See also

- [How It Works](https://docs.ravendb.net/7.2/server/ongoing-tasks/cdc-sink/how-it-works.md)
- [Monitoring](https://docs.ravendb.net/7.2/server/ongoing-tasks/cdc-sink/monitoring.md)
- [Patching](https://docs.ravendb.net/7.2/server/ongoing-tasks/cdc-sink/patching.md)
- [Failover and Consistency](https://docs.ravendb.net/7.2/server/ongoing-tasks/cdc-sink/failover-and-consistency.md)
- [PostgreSQL WAL Configuration](https://docs.ravendb.net/7.2/server/ongoing-tasks/cdc-sink/source-database-setup/postgres/wal-configuration.md)
- [PostgreSQL Permissions and Roles](https://docs.ravendb.net/7.2/server/ongoing-tasks/cdc-sink/source-database-setup/postgres/permissions-and-roles.md)
- [PostgreSQL REPLICA IDENTITY](https://docs.ravendb.net/7.2/server/ongoing-tasks/cdc-sink/source-database-setup/postgres/replica-identity.md)
