Subscriptions and groups¶
Problems with replication itself: runs that don't start, members that need a new baseline, changes that can't be applied, and errors while creating subscriptions. Start with the group's or member's status and message (see Status values), then its replication events.
Replications don't run¶
Symptom
Snapshot runs, baselines or incremental groups don't start, or stay waiting.
What to do
- Check that the Replicator Service is running, and the service of its control database (SQL Server or Db2) if it's on the same computer (see Start and stop the service). Check that the source and destination databases are available.
- Check the connection limits. When all of a source's or destination's Maximum Number of Connections are in use, no new replication with it starts until a connection is released; the waiting requests show Waiting (see Connections). A replication waits up to two hours for a connection; then it's cancelled and the error is logged in the service log. If many replications use the same source or destination at the same time, raise its Maximum Number of Connections (see Source properties and Destination properties).
- Release idle connections sooner: lower the Connection time limit (minutes) on the Connection Pools tab of Service settings, and the Maximum Connection Pool Size of the sources and destinations.
- For a SQL Server control database or destination, check that your SQL Server edition allows enough concurrent work for the number of replications you run at the same time (see Microsoft's documentation of the editions).
"Baseline snapshot is required, according to Capture Agent"¶
Symptoms
- Many subscriptions of one source need a baseline at the same time, often after maintenance or an outage. The Data Replicator Manager shows "Baseline snapshot is required, according to Capture Agent" (see Member status); with Automatic Snapshot on, the baselines start by themselves.
-
The Capture Agent's log (the Diagnostics tab in the SQDR Control Center) shows, for each table:
ChangePropagator.onInvalidLogPosition: New baseline snapshot needed for SCHEMA.TABLEor, for SQL Server:
MsSqlCdcChangePropagator.processOneLogRecord: Min LSN is above current read position in CDC change table for SCHEMA.TABLE
Cause
The Capture Agent keeps its position in the source database's log. When the log records at that position no longer exist, it can't know what changed in between. It marks the subscriptions of the tables it reads there as needing a baseline, and continues reading from the current position. The log records were removed by the source database or its administrators, usually while the agent was stopped or behind:
| Source | What removed the log records | What the agent log shows |
|---|---|---|
| Db2 for i | Journal receivers were deleted before the agent read them, for example by a journal with DLTRCV(*YES) while the Stelo Capture exit program wasn't protecting them. |
CPF9801 from QjoRetrieveJournalEntries, then onInvalidLogPosition. |
| Oracle | Archived redo logs were deleted (for example by a backup job) before the agent read them. | OracleFileLogMiner.reInitialize: The transaction log file for SCN=... has been deleted. |
| SQL Server (Change Data Capture) | The CDC cleanup job removed changes older than its retention (4320 minutes, 3 days, by default), and the agent was stopped or behind for longer. | Min LSN is above current read position in CDC change table |
| PostgreSQL | PostgreSQL invalidated the agent's replication slot (sqdrn) because it held back more WAL than the server allows. |
cannot read from logical replication slot "sqdrn" ... This slot has been invalidated because it exceeded the maximum reserved size. |
What to do
- Find out why the log records were removed (see the table) and fix that first, or the next baselines are lost the same way.
- Baseline the affected subscriptions: leave Automatic Snapshot on, or Run each group (see Incremental groups). For large tables, choose a quiet time (see Keep Automatic Snapshot on).
- PostgreSQL: an invalidated slot can't be used again. Contact Stelo Support before you change the Capture Agents.
Until a subscription is baselined, the group can still apply changes that were staged before the position was lost. That's expected: it doesn't mean the table is in step with the source.
Prevention
Keep the source's logs at least as long as the longest time a Capture Agent may be stopped or behind, including maintenance windows and weekends (see Keep the source's journals and logs in check).
- Db2 for i: keep the exit program registered, or let your own job delete receivers only after Stelo Capture has read them (see Db2 for i journal receivers and A table is re-baselined over and over).
- Oracle: make sure backup and archive-log deletion policies keep the archived logs until the Capture Agent has read them. For XStream, see Re-creating the XStream outbound server.
-
SQL Server: raise the CDC cleanup retention above your longest expected outage. Stelo Support suggests 7 days (10080 minutes):
EXEC sys.sp_cdc_change_job @job_type = N'cleanup', @retention = 10080; EXEC sys.sp_cdc_help_jobs;A longer retention keeps more rows in the CDC change tables.
-
PostgreSQL: watch the SQDR slots, and don't leave Capture Agents stopped for long.
wal_statuslostmeans the slot is invalidated:SELECT slot_name, active, wal_status FROM pg_replication_slots;
Other reasons for unexpected baselines
- A second Replicator Service uses the same Capture Agent. A cloned or test server that still has a copy of the production configuration and a running Replicator Service interferes with the production groups: subscriptions become orphaned or are re-baselined, for example after every reboot. Keep the Replicator Service on a copy stopped and set to Disabled (see The standard stop).
- A startup mode other than Normal. Warm (restored) clears the saved log position: chosen by mistake, for example to restart an agent that shows a warning, changes made while the agent was stopped aren't captured, and the affected tables need a baseline. Force New Baselines baselines every subscription. Use them only for the situations in Startup mode; to restart an agent, use Start/Restart with the mode left at Normal.
- A Db2 for i table keyed by RRN was reorganized. See The RRN or ROWID column.
Duplicate key errors when applying changes¶
Symptom
An incremental group reports a polling error and retries the same batch of changes again and again, for example:
Error applying change data for subscription MYSUB: ODBC message: SQLSTATE 23000, native error 2627,
[Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Violation of PRIMARY KEY constraint 'PK_MYTABLE'. Cannot insert
duplicate key in object 'dbo.MYTABLE'. The duplicate key value is (...).
On a Db2 destination the error is SQL0803N (SQLCODE -803, SQLSTATE 23505). With Batch or Sequence, the whole
batch is rolled back and tried again, so the group makes no progress until the conflict is removed (see
When a change can't be applied).
Cause
A unique key on the destination table doesn't match the replication key SQDR uses, although the source has no duplicate. Most often:
- A destination table you created yourself, with Use existing table for baseline. SQDR doesn't create its index on
the replication key for such a table, and if the table's own primary key is on other columns (for example columns
the subscription transforms, while SQDR replicates by RRN), inserts collide on that key. The baseline's replication
events show the
CREATE INDEXstatement to run ("Use existing specified - verify that a suitable index exists over destination columns"). - A primary key or unique index added at the destination on other columns, or values that differ at the source but become equal at the destination (a case-insensitive collation, less precise timestamps).
For all the causes, see Duplicate keys and duplicate rows.
What to do
Get the group running again, with one of these:
- Delete the conflicting row at the destination. The key value is in the error message. The next retry applies the batch and the group resumes, without a baseline.
- Run a new baseline of the subscription.
- Switch the group to Merge for a short time. Merge matches rows on the replication key and updates a row that already exists instead of inserting it again. This helps when the destination already holds the row with the same replication key; it doesn't help when the conflict is on another destination key. Switch back to Batch once the batch is applied. Merge must be available for the destination (see How Merge works).
Then fix the cause:
- Compare the source table's key, the subscription's replication key, and the destination table's primary key and unique indexes (see Check what SQDR created).
- For a table created outside SQDR, create the index on the replication key that the baseline's events show.
- Remove destination unique keys on other columns, or make them match the replication key (see Keep destination keys the same as the replication key).
Prevention
- When you use existing destination tables, create the replication-key index after the first baseline (see What the Replicator Service creates).
- Don't add unique keys on other columns to replicated tables.
If rows are missing or extra after a baseline rather than rejected, see Keep destination keys the same as the replication key.
Polling error although the changes were applied: a trigger on the destination table¶
Symptom
An incremental group reports a polling error, although the changes reached the destination.
Cause
A trigger on the destination table returned an error to SQDR, or changed the row count of SQDR's statement, for example because of a logic error in the trigger.
What to do
Fix the trigger so that it doesn't change the return code or the row count of the statement that SQDR runs. On a SQL
Server destination, handle errors in the trigger with TRY...CATCH and check @@ERROR (see Microsoft's documentation
of @@ERROR and
TRY...CATCH). See also
Polling errors.
No source table or column list in the subscription properties¶
Symptom
In the Subscription Wizard or the subscription's properties, Refresh on the Source tab lists no source tables, or Rebuild Column List on the Columns tab lists no columns; after a while an error appears.
Cause
All of the source's Maximum Number of Connections are in use, for example by running replications or idle pooled connections. The Replicator Service waits up to 60 seconds for a connection to the source to read the tables or columns, then cancels the request and shows an error.
What to do
- Requests that wait for a connection show Waiting (see Connections).
- Raise the source's Maximum Number of Connections (see Source properties).
- Release idle connections sooner: lower the Connection time limit (minutes) on the Connection Pools tab of Service settings, and the Maximum Connection Pool Size of the sources and destinations.
"SQLCODE=-206, SQLSTATE=42703" adding an incremental subscription with criteria¶
Symptom
Creating an incremental subscription with a criteria fails with an error like:
Failed to add incremental subscription at Capture Agent for source table 'myschema.mytab'. Snapshot could not be
started. Error: Stored procedure SQDR.ADDSUBSCRIPTION ... returned error 11. ...
Failed to add subscription: DB2 SQL Error: SQLCODE=-206, SQLSTATE=42703, SQLERRMC=ID ...
Cause
For an incremental subscription, the Capture Agent also evaluates the criteria, to pass on only changes to matching
rows (see Criteria). It doesn't find the column named after
SQLERRMC= as written in the criteria.
What to do
Put the column names in the criteria in double quotes, for example WHERE "ZIP" > 89999 AND "ZIP" < 95000.