← Back to Quickstarts

Vendor Nuances — Oracle (Log-Based CDC)

Practical prerequisites, quick checks, performance knobs, and a “first-aid” section for common failures.

What you must have before turning on CDC

Quick Health Checks (copy/paste)

Untested: not run against an Oracle database. This repository has no Oracle in its test setup; try these on a test instance first.

Archivelog & Redo Status

SELECT log_mode FROM v$database;
SELECT sequence#, bytes/1024/1024 MB, archived, status
FROM v$log ORDER BY first_time DESC FETCH FIRST 10 ROWS ONLY;

Supplemental Logging

-- database-wide
SELECT supplemental_log_data_min, supplemental_log_data_all FROM v$database;

-- table-level (confirm keys/columns logged for merges on keyless tables)
SELECT owner, table_name, log_group_name, always, log_group_type
FROM dba_log_groups
ORDER BY owner, table_name;

Current Redo Pressure

SELECT TO_CHAR(first_time,'YYYY-MM-DD HH24:MI') AS first_time,
       COUNT(*) AS switches
FROM v$log_history
WHERE first_time > SYSDATE - 1/24   -- last hour
GROUP BY TO_CHAR(first_time,'YYYY-MM-DD HH24:MI')
ORDER BY 1 DESC;

Connector Snapshot Sanity

  • Scope restricted: include only necessary schemas/tables.
  • Long-running transactions identified (they can stall snapshot start).
  • Redo retention ≥ expected snapshot duration.
  • If tables lack PKs, ensure table-level log groups capture enough columns for deterministic merges.

Nice-to-have SQL for big snapshots

Untested: not run against an Oracle database.

-- largest tables by size
SELECT owner, segment_name, bytes/1024/1024 MB
FROM dba_segments
WHERE segment_type='TABLE'
ORDER BY bytes DESC FETCH FIRST 20 ROWS ONLY;

Performance Knobs (choose carefully, measure after each change)

Common Failure → First Aid

  • Duplicates after restarts: switch the sink to idempotent MERGE/UPSERT keyed by a primary key and guarded on the (position, tie-break) pair: the source log position (SCN) plus a single orderable tie-break column; if you use both rs_id and ssn, compare them as separate columns (rs_id is a string), as the merge cookbook note explains: do not concatenate them as text. The tie-break is needed because the SCN can repeat across changes in one transaction (see Making Sinks Bulletproof); then replay last N events.
  • Missed updates: enable table-level supplemental logging for key columns (or all columns for keyless) and re-snapshot.
  • Dictionary mismatch / DDL errors: pause, capture the DDL, align connector schema evolution settings, then resume from a safe SCN.
  • Redo switch storm: reduce snapshot scope or increase redo log size; avoid concurrent heavy maintenance jobs.
  • SCN gaps / “log not found”: extend archive retention; if a gap exists, plan a clean re-snapshot of affected tables.

Observability

  • Expose SCN / commit timestamp per event (headers/columns) all the way to the sink (for lag metrics only, never for ordering).
  • Emit connector task metrics (lag, batches/sec, records/sec) and alert on flatlining progress.
  • Dead-letter queue (DLQ) enabled with payload + error string for triage.

Duplicate / Latest-wins Checks (sink)

Untested: not run against an Oracle database. The latest-wins query ranks by the (position, tie-break) pair, not by the SCN alone; tie_break stands for a single orderable column; if you use both rs_id and ssn, compare them as separate columns (rs_id is a string), as the merge cookbook note explains: do not concatenate them as text. It can also be your own within-transaction ordinal (verify the ordering semantics for your Debezium version).

-- generic duplicate check (replace target & pk)
SELECT COUNT(*) AS rows, COUNT(DISTINCT pk) AS distinct_keys FROM target;

-- latest-wins per key by (position, tie-break), never by SCN alone
-- (replace names; tie_break = one orderable column, e.g. your own ordinal;
-- never rs_id and ssn concatenated as text)
SELECT business_id, source_scn AS last_scn, tie_break AS last_tie_break, events
FROM (
  SELECT business_id, source_scn, tie_break,
         COUNT(*) OVER (PARTITION BY business_id) AS events,
         ROW_NUMBER() OVER (PARTITION BY business_id
                            ORDER BY source_scn DESC, tie_break DESC) AS rn
  FROM history_or_stage
)
WHERE rn = 1;

Upgrade Checklist

Acceptance Criteria