:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
chore(warehouse-sources): remove the last legacy cdc lane leftovers (#111761)
Daniel RC20741eb96da2
diff --git a/docs/internal/cdc-buffered-ingress-runbook.md b/docs/internal/cdc-buffered-ingress-runbook.mdindex bae3f379ebad..4beff66b2198 100644--- a/docs/internal/cdc-buffered-ingress-runbook.md+++ b/docs/internal/cdc-buffered-ingress-runbook.md@@ -144,20 +144,12 @@ queued. The run returns an empty response, which no-ops the tick and keeps the slisted, so nothing is read, nothing is deleted, and the tick never counts as proof that a file wasconsumed. The next scheduled run picks the buffer up once the queue has drained.-## Leftover legacy state+## The `legacy_lane_retired` marker-Capture used to deliver some tables' changes itself, on the retired legacy lane.-The code that converted what that lane left behind is gone.-Every source that still read as legacy when it was removed is marked `cdc_broken`, so Repair CDC is its only way back.-Repair CDC resets every table, recreates the slot and resumes the table schedules, so no legacy state survives it.--Two leftovers remain in the data, and nothing reads them:--- `cdc_ingest_mode` in a source's `job_inputs`.- CDC setup and Repair CDC still write `buffered`, and the API still keeps the key on a PATCH.- A rollback to the release that converted legacy sources would read a source without it as legacy and empty its unconsumed buffer.-- `cdc_deferred_runs` in a table's `sync_type_config`.- A resync, a table-mode change and Repair CDC remove it.+A few sources carry `cdc_broken` with the reason `legacy_lane_retired`.+Their capture had stopped before every table's changes went through the buffer, and the marker was set by hand so that Repair CDC is their only way back.+No code sets that reason.+Repair CDC clears it like any other marker.## When a schedule stops firing@@ -293,9 +285,6 @@ towards usage: the `_cdc` table for `cdc_only`, and the consolidated table for ``both`. So `both` bills the same as `consolidated`, and keeping a history table alongside the mergedone costs nothing extra.-The retired legacy lane wrote the two tables from two `ExternalDataJob` rows and counted each event-twice, so a `both` source's synced-row count roughly halved when it moved to the buffer.-**The merge lane re-bills the rows at its position until the file holding them is deleted.** Itkeeps every row at its position deliberately, since dropping one would lose a later event for thesame key at that same commit, and a kept row is a staged row. That happens only when the filediff --git a/products/warehouse_sources/backend/ad_hoc_sync.py b/products/warehouse_sources/backend/ad_hoc_sync.pyindex e1dedaeb70e7..48aa620e42f7 100644--- a/products/warehouse_sources/backend/ad_hoc_sync.py+++ b/products/warehouse_sources/backend/ad_hoc_sync.py@@ -129,7 +129,7 @@ def trigger_ad_hoc_sync(# deleting changes an in-flight run wrote.updates[CDC_SNAPSHOT_LANE_KEY] = BUFFER_LANEupdates["cdc_mode"] = "snapshot"- removes += ["cdc_last_log_position", "cdc_deferred_runs"]+ removes.append("cdc_last_log_position")extra_model_fields["initial_sync_complete"] = Falseif paused_now:updates["admin_unpause_schedule_after_run"] = Truediff --git a/products/warehouse_sources/backend/presentation/views/external_data_schema.py b/products/warehouse_sources/backend/presentation/views/external_data_schema.pyindex 8619f0dfe536..c3a12961499e 100644--- a/products/warehouse_sources/backend/presentation/views/external_data_schema.py+++ b/products/warehouse_sources/backend/presentation/views/external_data_schema.py@@ -177,7 +177,7 @@ def _reset_cdc_for_full_resnapshot(instance: ExternalDataSchema) -> None:# sync_type_config writes (and the status/initial_sync_complete save below skips the JSON# column, leaving no second window for the merged config to be overwritten).updates: dict[str, Any] = {"reset_pipeline": True, "cdc_mode": "snapshot"}- removes = ["cdc_last_log_position", "cdc_deferred_runs", CDC_RESET_PENDING_KEY]+ removes = ["cdc_last_log_position", CDC_RESET_PENDING_KEY]if resnapshot_stays_in_buffer(instance):updates[CDC_SNAPSHOT_LANE_KEY] = BUFFER_LANEinstance.sync_type_config = update_sync_type_config_keys(@@ -1126,7 +1126,6 @@ class ExternalDataSchemaSerializer(UserAccessControlSerializerMixin, serializerspayload["cdc_mode"] = "snapshot"for stale_key in ("cdc_last_log_position",- "cdc_deferred_runs",CDC_RESET_PENDING_KEY,CDC_SNAPSHOT_LANE_KEY,):@@ -2055,7 +2054,7 @@ class ExternalDataSchemaViewset(TeamAndOrgViewSetMixin, viewsets.ModelViewSet):if cdc_resync:# Reset CDC state so the next run does a full re-snapshotupdates["cdc_mode"] = "snapshot"- removes = ["cdc_last_log_position", "cdc_deferred_runs", CDC_RESET_PENDING_KEY]+ removes = ["cdc_last_log_position", CDC_RESET_PENDING_KEY]# Without the marker, the next capture run would empty the buffer, deleting changes a# capture run already in progress wrote after the snapshot started reading.if resnapshot_stays_in_buffer(instance):diff --git a/products/warehouse_sources/backend/presentation/views/external_data_source/helpers.py b/products/warehouse_sources/backend/presentation/views/external_data_source/helpers.pyindex bd810b0f3653..8811572c9291 100644--- a/products/warehouse_sources/backend/presentation/views/external_data_source/helpers.py+++ b/products/warehouse_sources/backend/presentation/views/external_data_source/helpers.py@@ -360,9 +360,6 @@ _CDC_EXPOSED_JOB_INPUT_KEYS = {"cdc_lag_warning_threshold_mb","cdc_lag_critical_threshold_mb","cdc_consistent_point",- # Set by CDC setup and Repair CDC, never by the API. A worker on a release that reads it treats a- # source without it as legacy and empties its buffer, so a PATCH must keep it for a rollback.- "cdc_ingest_mode",}diff --git a/products/warehouse_sources/backend/temporal/data_imports/cdc/activities.py b/products/warehouse_sources/backend/temporal/data_imports/cdc/activities.pyindex 3e2f8486592e..f69dbff7a2b0 100644--- a/products/warehouse_sources/backend/temporal/data_imports/cdc/activities.py+++ b/products/warehouse_sources/backend/temporal/data_imports/cdc/activities.py@@ -104,22 +104,17 @@ SLOT_INVALIDATION_RECOVERY_MESSAGE = ()-def _merge_pending_reset(- config: dict[str, typing.Any], *, clear_deferred_runs: bool, awaiting_slot: bool-) -> dict[str, typing.Any]:+def _merge_pending_reset(config: dict[str, typing.Any], *, awaiting_slot: bool) -> None:"""Merge a reset into the table's pending one. Read under the row lock, so a request's fields survive.- `clear_deferred_runs` accumulates: a reset that owes the drop keeps owing it until one happens.`awaiting_slot` is this reset's own answer, because only the reset that is waiting for a slotholds the table back, and slot recovery clears the wait."""current = config.get(CDC_RESET_PENDING_KEY)fields = dict(current) if isinstance(current, dict) else {}- fields["clear_deferred_runs"] = clear_deferred_runs or bool(fields.get("clear_deferred_runs"))fields["awaiting_slot"] = awaiting_slotfields["generation"] = next_reset_generation(fields)config[CDC_RESET_PENDING_KEY] = fields- return fields# The sweeper's auto-drop must fire below the engine's own retention cap, otherwise the@@ -942,9 +937,7 @@ class CDCExtractActivity:return Nonereturn pending if isinstance(pending, dict) else {}- def _reset_schema_to_snapshot(- self, schema: ExternalDataSchema, *, clear_deferred_runs: bool = False, awaiting_slot: bool = False- ) -> bool:+ def _reset_schema_to_snapshot(self, schema: ExternalDataSchema, *, awaiting_slot: bool = False) -> bool:"""Put a schema back into snapshot mode so its own schedule re-syncs it from scratch.Returns False when a sync of the table could still hand over, which leaves the reset pending.@@ -957,12 +950,7 @@ class CDCExtractActivity:self._pause_schema_schedule(schema)stopping = cancel_running_sync(schema)if stopping is not None or has_queued_batches(schema):- self._defer_reset(- schema,- clear_deferred_runs=clear_deferred_runs,- awaiting_slot=awaiting_slot,- stopping_workflow_id=stopping,- )+ self._defer_reset(schema, awaiting_slot=awaiting_slot, stopping_workflow_id=stopping)return False# The re-seeding snapshot starts after this run, so it covers every change this run read.# Pending changes go too, because a change from before a TRUNCATE would bring back rows.@@ -976,9 +964,7 @@ class CDCExtractActivity:# Pending until the schedule is unpaused, so a failed unpause repeats on the next run.def _merge_pending(config: dict[str, typing.Any]) -> None:- merged = _merge_pending_reset(config, clear_deferred_runs=clear_deferred_runs, awaiting_slot=awaiting_slot)- if merged["clear_deferred_runs"]:- config.pop("cdc_deferred_runs", None)+ _merge_pending_reset(config, awaiting_slot=awaiting_slot)# reset_pipeline forces the batch import to wipe the table first (handle_reset_or_full_refresh),# preventing pre-truncate rows from surviving a TRUNCATE or lost-slot re-snapshot. Later runs@@ -995,12 +981,7 @@ class CDCExtractActivity:return Truedef _defer_reset(- self,- schema: ExternalDataSchema,- *,- clear_deferred_runs: bool,- awaiting_slot: bool,- stopping_workflow_id: str | None,+ self, schema: ExternalDataSchema, *, awaiting_slot: bool, stopping_workflow_id: str | None) -> None:"""Leave the table out of capture until a later run can reset it."""if self.batcher is not None:@@ -1008,7 +989,7 @@ class CDCExtractActivity:self._tables_awaiting_reset.add(schema.name)def _merge_pending(config: dict[str, typing.Any]) -> None:- _merge_pending_reset(config, clear_deferred_runs=clear_deferred_runs, awaiting_slot=awaiting_slot)+ _merge_pending_reset(config, awaiting_slot=awaiting_slot)self._update_schema_sync_type_config(schema, mutate=_merge_pending)self._schema_log(schema).info("cdc_reset_waits_for_running_sync", stopping_workflow_id=stopping_workflow_id)@@ -1220,7 +1201,7 @@ class CDCExtractActivity:# free to start a snapshot before capture has a point to resume from.reset_schemas = []for schema in self.cdc_schemas:- if self._reset_schema_to_snapshot(schema, clear_deferred_runs=True, awaiting_slot=True):+ if self._reset_schema_to_snapshot(schema, awaiting_slot=True):reset_schemas.append(schema)schema.status = ExternalDataSchema.Status.FAILEDschema.latest_error = SLOT_INVALIDATION_RECOVERY_MESSAGEdiff --git a/products/warehouse_sources/backend/temporal/data_imports/cdc/companion_jobs.py b/products/warehouse_sources/backend/temporal/data_imports/cdc/companion_jobs.pyindex 04d5c77c557d..2acd0b9500a5 100644--- a/products/warehouse_sources/backend/temporal/data_imports/cdc/companion_jobs.py+++ b/products/warehouse_sources/backend/temporal/data_imports/cdc/companion_jobs.py@@ -24,9 +24,8 @@ COMPANION_RETIRED_ERROR = "Extraction ended before this table's changes were wridef retire_companion_job(job_id: str) -> None:"""Take one Running companion job terminal, touching nothing else.- Written straight onto the row, as the legacy CDC path retires its own companions: the shared- status helper would repaint the customer's schema FAILED and fire a failure digest for a row- that is not the schema's own.+ Written straight onto the row, because the shared status helper would repaint the customer's+ schema FAILED and fire a failure digest for a row that is not the schema's own."""from products.warehouse_sources.backend.models.external_data_job import ExternalDataJobdiff --git a/products/warehouse_sources/backend/temporal/data_imports/cdc/repair.py b/products/warehouse_sources/backend/temporal/data_imports/cdc/repair.pyindex c80642f8f462..ccb9d998729a 100644--- a/products/warehouse_sources/backend/temporal/data_imports/cdc/repair.py+++ b/products/warehouse_sources/backend/temporal/data_imports/cdc/repair.py@@ -4,8 +4,7 @@ Recovery counterpart of ``broken.mark_cdc_broken``: once the change-stream resourecreated (the safety net dropped the slot, or someone dropped it on the source database),repair recreates the engine-side resources against the stored CDC config, resets everyactive CDC schema to snapshot mode so it re-syncs from current table state, clears the-``cdc_broken`` markers, and resumes the paused schedules. The new slot starts on buffered-ingress, so a repaired legacy source comes back buffered.+``cdc_broken`` markers, and resumes the paused schedules.WAL between the old slot's last confirmed position and the new slot's consistent point isgone — the re-snapshot covers current rows, but intermediate changes in that gap (including@@ -130,8 +129,7 @@ def _repair_locked(source: ExternalDataSource) -> int:# Reset schemas before touching the slot (same ordering as the extraction activity's# slot-invalidation recovery): if recreation fails below, a re-run repeats idempotently- # and no schema keeps streaming across the gap unnoticed. Deferred runs left by the retired- # legacy lane are dropped: the re-snapshot supersedes them. The `cdc_broken` markers+ # and no schema keeps streaming across the gap unnoticed. The `cdc_broken` markers# deliberately survive this step: they are the retry gate.for schema_id in all_cdc_schema_ids:if schema_id in handed_over:@@ -140,7 +138,7 @@ def _repair_locked(source: ExternalDataSource) -> int:schema_id,source.team_id,updates={"cdc_mode": "snapshot", "reset_pipeline": True},- removes=["cdc_last_log_position", "cdc_deferred_runs", CDC_RESET_PENDING_KEY],+ removes=["cdc_last_log_position", CDC_RESET_PENDING_KEY],extra_model_fields={"initial_sync_complete": False},)diff --git a/products/warehouse_sources/backend/temporal/data_imports/cdc/snapshot_lane.py b/products/warehouse_sources/backend/temporal/data_imports/cdc/snapshot_lane.pyindex fbae8c5a8c56..e5d8c64f64fb 100644--- a/products/warehouse_sources/backend/temporal/data_imports/cdc/snapshot_lane.py+++ b/products/warehouse_sources/backend/temporal/data_imports/cdc/snapshot_lane.py@@ -182,7 +182,6 @@ def stage_handed_over_reset(config: dict[str, Any], *, awaiting_slot: bool = Fal"""current = config.get(CDC_RESET_PENDING_KEY)fields = dict(current) if isinstance(current, dict) else {}- fields["clear_deferred_runs"] = Truefields["trigger"] = Trueif awaiting_slot:fields["awaiting_slot"] = Truediff --git a/products/warehouse_sources/backend/temporal/data_imports/cdc/tests/test_extract_activity.py b/products/warehouse_sources/backend/temporal/data_imports/cdc/tests/test_extract_activity.pyindex fb505a97dc3e..b043cf5f1c4e 100644--- a/products/warehouse_sources/backend/temporal/data_imports/cdc/tests/test_extract_activity.py+++ b/products/warehouse_sources/backend/temporal/data_imports/cdc/tests/test_extract_activity.py@@ -127,8 +127,7 @@ def _fake_update_schema_sync_type_config(schema, *, updates=None, removes=None,@pytest.fixture(autouse=True)def _stub_app_db_writes():- # The real sync_type_config merge and the legacy-state conversion both go to the app DB, which- # these mock-only tests don't have. The conversion has its own tests.+ # The real sync_type_config merge goes to the app DB, which these mock-only tests don't have.with (patch("products.warehouse_sources.backend.temporal.data_imports.cdc.activities.cancel_running_sync",@@ -2048,9 +2047,9 @@ class TestBufferedIngressCapture:@parameterized.expand([- ("sync_still_stopping", "users-snapshot", {"clear_deferred_runs": False}, True),- ("sync_stopped", None, {"clear_deferred_runs": False}, False),- ("sync_stopped_after_a_request_reset", None, {"clear_deferred_runs": True, "trigger": True}, False),+ ("sync_still_stopping", "users-snapshot", {"awaiting_slot": False}, True),+ ("sync_stopped", None, {"awaiting_slot": False}, False),+ ("sync_stopped_after_a_request_reset", None, {"trigger": True}, False),])def test_a_pending_reset_finishes_before_the_read_once_the_sync_stopped(@@ -2092,7 +2091,7 @@ class TestBufferedIngressCapture:# the request that handed the reset over would have recreated the schedule itself.source = _make_source()schema = _make_schema("users", cdc_mode="streaming", source=source)- schema.sync_type_config["cdc_reset_pending"] = {"clear_deferred_runs": True, "trigger": True}+ schema.sync_type_config["cdc_reset_pending"] = {"trigger": True}events = [_make_event(op="I", position="0/100", columns={"id": 1})]with (@@ -2118,8 +2117,8 @@ class TestBufferedIngressCapture:@parameterized.expand([- ("a_different_reset", {"clear_deferred_runs": False}),- ("the_same_reset_again", {"clear_deferred_runs": True, "trigger": True}),+ ("a_different_reset", {"awaiting_slot": False}),+ ("the_same_reset_again", {"trigger": True}),])def test_a_reset_staged_while_the_snapshot_was_starting_is_left_pending(self, _name, pending):@@ -2158,7 +2157,7 @@ class TestBufferedIngressCapture:# is not the only way out, or a failure right after the recreation would strand the table.source = _make_source()schema = _make_schema("users", cdc_mode="streaming", source=source)- schema.sync_type_config["cdc_reset_pending"] = {"clear_deferred_runs": True, "awaiting_slot": True}+ schema.sync_type_config["cdc_reset_pending"] = {"awaiting_slot": True}events = [_make_event(op="I", position="0/100", columns={"id": 1})]with (@@ -2174,7 +2173,7 @@ class TestBufferedIngressCapture:unpause.assert_not_called()assert capture.purge.called is Falseassert capture.buffer.write_batch.called is False- assert schema.sync_type_config["cdc_reset_pending"] == {"clear_deferred_runs": True, "awaiting_slot": False}+ assert schema.sync_type_config["cdc_reset_pending"] == {"awaiting_slot": False}@parameterized.expand([diff --git a/products/warehouse_sources/backend/temporal/data_imports/pipelines/pipeline_v3/lanes.py b/products/warehouse_sources/backend/temporal/data_imports/pipelines/pipeline_v3/lanes.pyindex df98111a2a20..9069e2a9d6f7 100644--- a/products/warehouse_sources/backend/temporal/data_imports/pipelines/pipeline_v3/lanes.py+++ b/products/warehouse_sources/backend/temporal/data_imports/pipelines/pipeline_v3/lanes.py@@ -4,8 +4,7 @@ Kept apart from `PipelineV3` on purpose: every other source runs the base class,the single-table path it has always been. Only a source that declares `SourceResponse.lanes`gets this subclass, so nothing in here can change what a single-table run does.-Each table beyond the first gets its own `ExternalDataJob`, the way the legacy CDC extraction-already writes a `both` schema (see `cdc/activities.py`). That is what keeps the queue out of it:+Each table beyond the first gets its own `ExternalDataJob`. That is what keeps the queue out of it:a job is where batch idempotency, staging paths, claim ordering and completion all hang, so twotables under one job would collide on every one of them, while two jobs are two ordinarysingle-table runs the loader already knows how to finish.@@ -160,7 +159,7 @@ class LanedPipelineV3(PipelineV3[ResumableData]):"workflow_run_id": None,# The history table has no destination mapping: delivery names the destination# table from the schema, and SCD2 rows merged by key there would clobber the- # consolidated table's rows. Legacy never delivered companion batches either.+ # consolidated table's rows."destination_ids": [],})@@ -218,10 +217,9 @@ class LanedPipelineV3(PipelineV3[ResumableData]):itself discards the batches it has not yet claimed once it sees the job Failed; the nextrun re-reads those files from the table's position, so nothing is lost, only re-staged.- Written directly, the way the legacy CDC path retires its own companion jobs. Going- through `update_external_job_status` would repaint the customer's schema FAILED and fire a- failure digest, and this runs from a `finally` on every attempt — including ones Temporal- retries and succeeds.+ Written directly. Going through `update_external_job_status` would repaint the customer's+ schema FAILED and fire a failure digest, and this runs from a `finally` on every attempt —+ including ones Temporal retries and succeeds."""for job_id in self._companion_job_ids:if job_id in self._final_sent_job_ids:diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/postgres/cdc/adapter.py b/products/warehouse_sources/backend/temporal/data_imports/sources/postgres/cdc/adapter.pyindex 9da6747ed7cc..5d7b0314c7fb 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/postgres/cdc/adapter.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/postgres/cdc/adapter.py@@ -245,9 +245,7 @@ class PostgresCDCAdapter:_recreate, _retry_logger, is_retryable=_is_dropped_or_connect_timeout)- # No code on this release reads the ingest mode. A worker on a release that reads it treats a- # source without it as legacy and empties its buffer, so a rollback needs the value.- return {"cdc_consistent_point": consistent_point, "cdc_ingest_mode": "buffered"}+ return {"cdc_consistent_point": consistent_point}def setup_resources(self,@@ -273,8 +271,6 @@ class PostgresCDCAdapter:"cdc_management_mode": management_mode,"cdc_slot_name": slot_name,"cdc_publication_name": pub_name,- # A rollback needs it, as in `recreate_slot`.- "cdc_ingest_mode": "buffered",}if management_mode == "posthog":diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/postgres/cdc/tests/test_adapter.py b/products/warehouse_sources/backend/temporal/data_imports/sources/postgres/cdc/tests/test_adapter.pyindex d8815d2aa539..36f66be8fc0d 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/postgres/cdc/tests/test_adapter.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/postgres/cdc/tests/test_adapter.py@@ -94,7 +94,6 @@ class TestSetupResourcesPreflight:"cdc_management_mode": "posthog","cdc_slot_name": "posthog_019ef4e83bfd","cdc_publication_name": "posthog_pub_019ef4e83bfd",- "cdc_ingest_mode": "buffered",}mock_create_slot.assert_not_called()mock_create_publication.assert_not_called()@@ -224,7 +223,7 @@ class TestRecreateSlot:fields = PostgresCDCAdapter().recreate_slot(source, tables=["users", "orders"])- assert fields == {"cdc_consistent_point": "0/AA", "cdc_ingest_mode": "buffered"}+ assert fields == {"cdc_consistent_point": "0/AA"}mock_drop.assert_called_once()assert mock_drop.call_args.args[1] == "posthog_slot"mock_create.assert_called_once()@@ -259,7 +258,7 @@ class TestRecreateSlot:fields = PostgresCDCAdapter().recreate_slot(source, tables=tables)- assert fields == {"cdc_consistent_point": "0/BB", "cdc_ingest_mode": "buffered"}+ assert fields == {"cdc_consistent_point": "0/BB"}mock_create_slot_and_pub.assert_called_once()assert mock_create_slot_and_pub.call_args.args[1:3] == ("posthog_slot", "posthog_pub")assert mock_create_slot_and_pub.call_args.kwargs["tables"] == expected_pairs@@ -314,7 +313,7 @@ class TestRecreateSlot:fields = PostgresCDCAdapter().recreate_slot(source, tables=["users"])- assert fields == {"cdc_consistent_point": "0/CC", "cdc_ingest_mode": "buffered"}+ assert fields == {"cdc_consistent_point": "0/CC"}assert mock_create_slot.call_count == 2assert mock_drop.call_count == 2@@ -344,7 +343,7 @@ class TestRecreateSlot:fields = PostgresCDCAdapter().recreate_slot(source, tables=["users"])- assert fields == {"cdc_consistent_point": "0/DD", "cdc_ingest_mode": "buffered"}+ assert fields == {"cdc_consistent_point": "0/DD"}assert mock_create_slot.call_count == 2assert mock_drop.call_count == 2diff --git a/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/create_job_model.py b/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/create_job_model.pyindex e0a63c91c553..3234503e9048 100644--- a/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/create_job_model.py+++ b/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/create_job_model.py@@ -165,10 +165,9 @@ def _verify_v3_lock_still_held(team_id: int, schema_id: uuid.UUID) -> None:raise V3PipelineLockLostError("v3 pipeline lock lost to another run before job creation")-# Per-run state, not configuration. `cdc_deferred_runs`, left on some schemas by the retired legacy-# CDC lane, reaches hundreds of KB, and `schema_metadata` is the source table's column list.-# Copying them onto every job row was most of the snapshot's storage cost.-_SNAPSHOT_EXCLUDED_CONFIG_KEYS = frozenset({"cdc_deferred_runs", "schema_metadata"})+# `schema_metadata` is the source table's column list, not configuration. Copying it onto every+# job row would be most of the snapshot's storage cost.+_SNAPSHOT_EXCLUDED_CONFIG_KEYS = frozenset({"schema_metadata"})def _build_schema_snapshot(schema: ExternalDataSchema) -> dict[str, Any]:diff --git a/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/tests/test_create_job_model.py b/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/tests/test_create_job_model.pyindex 9b05747a8361..4f8c3a7fe41f 100644--- a/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/tests/test_create_job_model.py+++ b/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/tests/test_create_job_model.py@@ -186,13 +186,12 @@ class TestEnrichmentPending:class TestBuildSchemaSnapshot:- def test_copies_the_config_without_the_per_run_state_blobs(self) -> None:+ def test_copies_the_config_without_the_column_list(self) -> None:config = {"incremental_field": "updated_at","incremental_field_last_value": "2026-09-01T00:00:00+00:00","reset_pipeline": True,"schema_metadata": {"columns": [{"name": "id", "type": "int"}]},- "cdc_deferred_runs": [{"run_id": "r1"}],}schema = ExternalDataSchema(name="Charge", sync_type="incremental", sync_type_config=dict(config))diff --git a/products/warehouse_sources/backend/tests/api/test_cdc_table_mode_patch.py b/products/warehouse_sources/backend/tests/api/test_cdc_table_mode_patch.pyindex eb8842ab9ad9..c22209394cf3 100644--- a/products/warehouse_sources/backend/tests/api/test_cdc_table_mode_patch.py+++ b/products/warehouse_sources/backend/tests/api/test_cdc_table_mode_patch.py@@ -88,7 +88,6 @@ def _make_cdc_source_and_schema(team,cdc_table_mode: str,cdc_last_log_position: str | None = "0/12345",- cdc_deferred_runs: list[dict] | None = None,initial_sync_complete: bool = True,) -> tuple[ExternalDataSource, ExternalDataSchema]:job_inputs = {@@ -110,8 +109,6 @@ def _make_cdc_source_and_schema(}if cdc_last_log_position is not None:sync_type_config["cdc_last_log_position"] = cdc_last_log_position- if cdc_deferred_runs is not None:- sync_type_config["cdc_deferred_runs"] = cdc_deferred_runsschema = ExternalDataSchema.objects.create(team=team,@@ -134,11 +131,8 @@ def _make_cdc_source_and_schema(("cdc_only", "both"),],)[email protected]("deferred_runs", [None, [{"job_id": "stale", "run_uuid": "stale", "batch_results": []}]])-def test_patch_cdc_table_mode_adding_target_triggers_resnapshot(- team, user, client: HttpClient, old_mode, new_mode, deferred_runs-):- source, schema = _make_cdc_source_and_schema(team, cdc_table_mode=old_mode, cdc_deferred_runs=deferred_runs)+def test_patch_cdc_table_mode_adding_target_triggers_resnapshot(team, user, client: HttpClient, old_mode, new_mode):+ source, schema = _make_cdc_source_and_schema(team, cdc_table_mode=old_mode)running_job = ExternalDataJob.objects.create(team=team,pipeline=source,@@ -175,7 +169,6 @@ def test_patch_cdc_table_mode_adding_target_triggers_resnapshot(assert schema.sync_type_config.get("cdc_snapshot_lane") == "buffer"assert schema.sync_type_config.get("cdc_mode") == "snapshot"assert schema.sync_type_config.get("cdc_last_log_position") is None- assert schema.sync_type_config.get("cdc_deferred_runs") is Noneassert schema.initial_sync_complete is Falseassert schema.sync_type_config.get("reset_pipeline") is Truemock_cancel.assert_called_once_with(running_job.workflow_id)@@ -219,11 +212,7 @@ def test_a_reset_is_left_to_capture_while_the_tables_sync_can_still_hand_over(teassert response.status_code == 200, response.contentschema.refresh_from_db()- assert schema.sync_type_config["cdc_reset_pending"] == {- "clear_deferred_runs": True,- "trigger": True,- "generation": 1,- }+ assert schema.sync_type_config["cdc_reset_pending"] == {"trigger": True, "generation": 1}assert "reset_pipeline" not in schema.sync_type_configassert schema.sync_type_config["cdc_mode"] == "streaming"assert schema.initial_sync_complete is True@@ -241,7 +230,7 @@ def test_a_hand_over_keeps_a_reset_that_is_still_waiting_on_a_slot(team, user, cExternalDataSchema.objects.filter(id=schema.id).update(sync_type_config={**schema.sync_type_config,- "cdc_reset_pending": {"clear_deferred_runs": False, "awaiting_slot": True},+ "cdc_reset_pending": {"awaiting_slot": True},})ExternalDataJob.objects.create(@@ -265,7 +254,6 @@ def test_a_hand_over_keeps_a_reset_that_is_still_waiting_on_a_slot(team, user, cassert response.status_code == 200, response.contentschema.refresh_from_db()assert schema.sync_type_config["cdc_reset_pending"] == {- "clear_deferred_runs": True,"trigger": True,"awaiting_slot": True,"generation": 1,diff --git a/products/warehouse_sources/backend/tests/api/test_external_data_schema.py b/products/warehouse_sources/backend/tests/api/test_external_data_schema.pyindex a0378caaa705..4e71c5327620 100644--- a/products/warehouse_sources/backend/tests/api/test_external_data_schema.py+++ b/products/warehouse_sources/backend/tests/api/test_external_data_schema.py@@ -3032,7 +3032,6 @@ class TestUpdateExternalDataSchema:{"cdc_mode": "streaming","cdc_last_log_position": "0/16B3748",- "cdc_deferred_runs": [{"run": 1}],"cdc_snapshot_lane": "buffer",},"posthog",@@ -3068,7 +3067,6 @@ class TestUpdateExternalDataSchema:assert schema.sync_type == ExternalDataSchema.SyncType.CDCassert schema.sync_type_config["cdc_mode"] == "snapshot"assert "cdc_last_log_position" not in schema.sync_type_config- assert "cdc_deferred_runs" not in schema.sync_type_configassert "cdc_snapshot_lane" not in schema.sync_type_configassert schema.initial_sync_complete is Falsediff --git a/products/warehouse_sources/backend/tests/api/test_external_data_source.py b/products/warehouse_sources/backend/tests/api/test_external_data_source.pyindex cef4bd12c9a5..33bd274048c8 100644--- a/products/warehouse_sources/backend/tests/api/test_external_data_source.py+++ b/products/warehouse_sources/backend/tests/api/test_external_data_source.py@@ -1205,7 +1205,6 @@ class TestExternalDataSource(APIBaseTest):"cdc_lag_warning_threshold_mb": 512,"cdc_lag_critical_threshold_mb": 1024,"cdc_consistent_point": "0/AA",- "cdc_ingest_mode": "buffered",},)@@ -1226,7 +1225,6 @@ class TestExternalDataSource(APIBaseTest):"cdc_lag_warning_threshold_mb": 1,"cdc_lag_critical_threshold_mb": 2,"cdc_consistent_point": "0/BAD",- "cdc_ingest_mode": "legacy",}},format="json",@@ -1243,7 +1241,6 @@ class TestExternalDataSource(APIBaseTest):assert str(source.job_inputs["cdc_lag_warning_threshold_mb"]) == "512"assert str(source.job_inputs["cdc_lag_critical_threshold_mb"]) == "1024"assert source.job_inputs["cdc_consistent_point"] == "0/AA"- assert source.job_inputs["cdc_ingest_mode"] == "buffered"@patch("products.warehouse_sources.backend.presentation.views.external_data_schema.external_data_workflow_exists",@@ -12022,7 +12019,6 @@ class TestRepairCDC(APIBaseTest):sync_type_config={"cdc_mode": "streaming","cdc_last_log_position": "0/123",- "cdc_deferred_runs": [{"run": "stale"}],"cdc_broken": BROKEN_MARKER,},)@@ -12069,7 +12065,6 @@ class TestRepairCDC(APIBaseTest):assert config["reset_pipeline"] is Trueassert "cdc_broken" not in configassert "cdc_last_log_position" not in config- assert "cdc_deferred_runs" not in configassert schema.initial_sync_complete is Falseassert schema.latest_error is None@@ -12307,7 +12302,6 @@ class TestRepairCDC(APIBaseTest):# `awaiting_slot`: the slot this table would snapshot against is gone until repair# recreates it, so a capture run firing meanwhile must hold the reset instead of starting.assert cdc_schema.sync_type_config["cdc_reset_pending"] == {- "clear_deferred_runs": True,"trigger": True,"awaiting_slot": True,"generation": 1,diff --git a/products/warehouse_sources/backend/tests/test_external_data_schema_admin.py b/products/warehouse_sources/backend/tests/test_external_data_schema_admin.pyindex 684cac904c4e..f58b80d109bc 100644--- a/products/warehouse_sources/backend/tests/test_external_data_schema_admin.py+++ b/products/warehouse_sources/backend/tests/test_external_data_schema_admin.py@@ -60,7 +60,7 @@ class TestExternalDataSchemaAdmin(BaseTest):def test_reset_streaming_cdc_flips_to_snapshot_non_billable(self) -> None:schema = self._schema(sync_type=ExternalDataSchema.SyncType.CDC,- sync_type_config={"cdc_mode": "streaming", "cdc_last_log_position": "0/ABC", "cdc_deferred_runs": [{}]},+ sync_type_config={"cdc_mode": "streaming", "cdc_last_log_position": "0/ABC"},initial_sync_complete=True,)@@ -79,7 +79,6 @@ class TestExternalDataSchemaAdmin(BaseTest):assert schema.cdc_mode == "snapshot"assert schema.initial_sync_complete is Falseassert "cdc_last_log_position" not in schema.sync_type_config- assert "cdc_deferred_runs" not in schema.sync_type_config# The re-snapshot must persist before the workflow starts (the source reloads cdc_mode), and# the job must be non-billable so the initial full refresh isn't charged to the customer.diff --git a/products/warehouse_sources/backend/tests/test_models.py b/products/warehouse_sources/backend/tests/test_models.pyindex d51a815a17bb..c254f710eb15 100644--- a/products/warehouse_sources/backend/tests/test_models.py+++ b/products/warehouse_sources/backend/tests/test_models.py@@ -631,14 +631,12 @@ class TestUpdateSyncTypeConfigKeys(BaseTest):assert schema.sync_type_config == {"cdc_mode": "streaming", "cdc_last_log_position": "0/200"}def test_removes_pop_keys(self) -> None:- schema = self._create(- {"cdc_mode": "snapshot", "cdc_last_log_position": "0/100", "cdc_deferred_runs": [{"x": 1}]}- )+ schema = self._create({"cdc_mode": "snapshot", "cdc_last_log_position": "0/100", "cdc_snapshot_lane": "buffer"})result = update_sync_type_config_keys(schema.id,self.team.pk,updates={"cdc_mode": "snapshot"},- removes=["cdc_last_log_position", "cdc_deferred_runs"],+ removes=["cdc_last_log_position", "cdc_snapshot_lane"],)assert result == {"cdc_mode": "snapshot"}schema.refresh_from_db()@@ -651,16 +649,16 @@ class TestUpdateSyncTypeConfigKeys(BaseTest):assert schema.sync_type_config == {"cdc_mode": "streaming"}def test_mutate_appends_inside_critical_section(self) -> None:- schema = self._create({"cdc_deferred_runs": [{"run_uuid": "a", "batch_results": []}]})+ schema = self._create({"runs": [{"run_uuid": "a", "batch_results": []}]})def _mutate(config: dict) -> None:- for entry in config["cdc_deferred_runs"]:+ for entry in config["runs"]:if entry["run_uuid"] == "a":entry["batch_results"].append({"s3_path": "s3://x"})update_sync_type_config_keys(schema.id, self.team.pk, mutate=_mutate)schema.refresh_from_db()- assert schema.sync_type_config["cdc_deferred_runs"][0]["batch_results"] == [{"s3_path": "s3://x"}]+ assert schema.sync_type_config["runs"][0]["batch_results"] == [{"s3_path": "s3://x"}]def test_apply_order_is_updates_removes_mutate(self) -> None:schema = self._create({"a": 1})@@ -753,13 +751,13 @@ class TestMarkInitialSyncComplete(BaseTest):[(# First completion of a CDC snapshot flips it to streaming; keys written- # concurrently by the CDC extract activity (deferred runs) must survive the flip.+ # concurrently by the CDC extract activity (its last run time) must survive the flip."cdc_snapshot_flips_to_streaming_preserving_other_keys","cdc",- {"cdc_mode": "snapshot", "cdc_deferred_runs": [{"run_uuid": "a"}], "dwh_storage_key": "users"},+ {"cdc_mode": "snapshot", "cdc_last_run_at": "2026-01-01T00:00:00+00:00", "dwh_storage_key": "users"},False,True,- {"cdc_mode": "streaming", "cdc_deferred_runs": [{"run_uuid": "a"}], "dwh_storage_key": "users"},+ {"cdc_mode": "streaming", "cdc_last_run_at": "2026-01-01T00:00:00+00:00", "dwh_storage_key": "users"},),(# Already-streaming CDC schema (re-run after a reset) completes without a config rewrite.