Skip to content

: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.

chore(data-warehouse): remove rolled-out warehouse pipeline flags (#109226)

Tom Owersa0ddfda22ede
diff --git a/posthog/settings/data_warehouse.py b/posthog/settings/data_warehouse.py
index d6ad4ec80312..e4b323e1a4c0 100644
--- a/posthog/settings/data_warehouse.py
+++ b/posthog/settings/data_warehouse.py
@@ -181,10 +181,3 @@ DATA_WAREHOUSE_V3_COALESCE_MAX_ROWS = get_from_env("DATA_WAREHOUSE_V3_COALESCE_M
DATA_WAREHOUSE_V3_COALESCE_MAX_BYTES = get_from_env(
"DATA_WAREHOUSE_V3_COALESCE_MAX_BYTES", 64 * 1024 * 1024, type_cast=int
)
-# A set may span consecutive runs of one schema. Off keeps every set inside one run. Off by default
-# until every loader pod runs a build that reads the `members` commit tag: an older pod that
-# redelivers a later run's member of a cross-run set cannot find that member's commit, and on an
-# append table that loads its rows a second time.
-DATA_WAREHOUSE_V3_COALESCE_ACROSS_RUNS = get_from_env(
- "DATA_WAREHOUSE_V3_COALESCE_ACROSS_RUNS", False, type_cast=str_to_bool
-)
diff --git a/products/warehouse_sources/backend/models/external_data_schema.py b/products/warehouse_sources/backend/models/external_data_schema.py
index d6c3e4c02113..76a865a15c7d 100644
--- a/products/warehouse_sources/backend/models/external_data_schema.py
+++ b/products/warehouse_sources/backend/models/external_data_schema.py
@@ -948,8 +948,8 @@ class ExternalDataSchema( # nosemgrep: semgrep.rules.security.prefer-uuid7-djan
def coarsen_requested(self) -> dict[str, Any] | None:
"""Set by `stage_warehouse_coarsening` to nominate this table for the coarsening rewrite.
- Nominating overrides the *policy* gates the automatic path applies (rollout flag, OOM history,
- layout age, minimum partition count) because an operator has looked at the table. It never
+ Nominating overrides the *policy* gates the automatic path applies (OOM history, layout age,
+ minimum partition count) because an operator has looked at the table. It never
overrides the *safety* checks: the controller still measures the live layout and refuses any
target that would not fit the memory budget, so a nomination can only ever be a no-op, never a
rewrite into partitions too big to merge. Consumed on the next evaluation either way.
diff --git a/products/warehouse_sources/backend/temporal/data_imports/README.md b/products/warehouse_sources/backend/temporal/data_imports/README.md
index eec6d7c0be3d..9a2a36b4e31e 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/README.md
+++ b/products/warehouse_sources/backend/temporal/data_imports/README.md
@@ -52,8 +52,8 @@ Week into month is the one transition that cannot be computed exactly, because I
Tuning and gating:
-- Gated by the `data-warehouse-auto-repartition` feature flag plus a 24h per-table cooldown. The flag can be released to a single schema (`schema_id = <id>`) before rolling out by team/org/project. Coarsening has its own flag, `data-warehouse-auto-coarsen`, released the same way.
-- **Repairing the existing backlog.** The automatic coarsening path will not reach a table that keeps recording OOM occurrences, and the tables most in need of coarsening are exactly the ones the unreliable OOM signal keeps firing on. `./manage.py stage_warehouse_coarsening` is the way in: it nominates tables by setting a `coarsen_requested` marker, and the next sync evaluates them. A nomination skips the policy gates (rollout flag, OOM history, layout age, minimum partition count) because an operator has made that call, but never the safety check: the controller still measures the live layout and refuses any target that would not fit the budget, so a nomination can only ever be a no-op. Nominated rewrites report `trigger_reason=coarsening_requested`. Dry run by default, `--limit` defaults low, and it is worth keeping low: a rewrite blocks that table's sync for as long as it runs, which is seconds for small tables and hours for the largest.
+- Gated by a 24h per-table cooldown. Neither direction is behind a feature flag.
+- **Repairing the existing backlog.** The automatic coarsening path will not reach a table that keeps recording OOM occurrences, and the tables most in need of coarsening are exactly the ones the unreliable OOM signal keeps firing on. `./manage.py stage_warehouse_coarsening` is the way in: it nominates tables by setting a `coarsen_requested` marker, and the next sync evaluates them. A nomination skips the policy gates (OOM history, layout age, minimum partition count) because an operator has made that call, but never the safety check: the controller still measures the live layout and refuses any target that would not fit the budget, so a nomination can only ever be a no-op. Nominated rewrites report `trigger_reason=coarsening_requested`. Dry run by default, `--limit` defaults low, and it is worth keeping low: a rewrite blocks that table's sync for as long as it runs, which is seconds for small tables and hours for the largest.
- **Putting back a table that was split too fine.** A table split from just over the budget cannot pass the coarsening safety check, because its coarser partitions are larger than half the budget. `./manage.py stage_warehouse_repartition --schema-id <id> --format <tier>` covers that case for datetime tables. The operator names the coarser tier, and the command measures the live table and refuses a target whose largest partition would be over the full budget. It then stages the same `repartition_pending` target as the admin page (`trigger_reason=admin`), and the next scheduled sync runs the rewrite. A scheduled full refresh skips the repartition step, so the target then waits for the sync after it. `--schema-id` repeats, and it is a dry run by default.
- The budget is tunable via the `DATA_WAREHOUSE_TARGET_PARTITION_BYTES` setting (default ~0.5 GB at-rest → ~10 GB worst-case merge). Worker pods are multi-tenant, so the budget leaves headroom for concurrent merges under the 29 GB pod limit rather than sizing to a single merge.
- The OOM-history override is tunable via `DATA_WAREHOUSE_REPARTITION_OOM_THRESHOLD` (default 3) and `DATA_WAREHOUSE_REPARTITION_OOM_WINDOW_DAYS` (default 7). An OOM-triggered rewrite of an under-budget table steps one tier finer per cooldown cycle, converging as the (still-recorded) OOMs continue.
@@ -169,8 +169,8 @@ That transport was removed; see git history for the old procedure.
HogQL does not read a table's Delta log. Post-load copies the live parquet files into a query folder under the schema's S3 prefix, and `DataWarehouseTable.queryable_folder` names the folder ClickHouse globs (`<folder>/**.parquet`). Readers must always see one complete generation, and S3 has no atomic multi-object update, so a folder is never rewritten while the pointer is on it.
-- **Default (timestamped folders).** Each sync copies every live file into a fresh `<table>__query_<epoch>_<hex>` folder and moves the pointer. Timestamped folders older than `S3_DELETE_TIME_BUFFER` are removed on later syncs. The cost scales with the table's file count, not with what the sync changed.
-- **Rotating slots** (`data-warehouse-double-buffered-query-folders`, per schema, released the same way as the repartition flags). The table rotates through `<table>__query_a`, `__query_b` and `__query_c`. A sync picks the slot that stopped being the pointer longest ago, lists it, copies in the live files it lacks, removes the files that are no longer live, and returns it for the pointer flip. The diff is against the listing, so a missed sync or a crash mid-reconcile heals on the next pass. A populated slot is rewritten only when it stopped being the pointer at least `S3_DELETE_TIME_BUFFER` ago; with three slots that instant is one whole sync interval before the current slot took over, so a table synced more often than the buffer still takes the incremental path. Every pointer move is recorded in `sync_type_config["query_folder_state"]` (the active folder, the job that published it, when each slot stopped being the pointer, and since when the record is contiguous). A move the record missed (a crash between the pointer write and the record, or a schema reset) restarts the record, and until it is older than the buffer only an empty slot is used; when no slot is safe the sync falls back to a fresh timestamped folder. A table's first syncs under the flag fill the empty slots in full, and reconciliation takes over from there. Turning the flag off returns the table to timestamped folders; the age-based cleanup never matches the slot names, so those folders stay behind until the table is deleted. DuckLake registration tells generations on a reused slot name apart by the job that published them, read from the same record.
+- **Timestamped folders.** A sync copies every live file into a fresh `<table>__query_<epoch>_<hex>` folder and moves the pointer. Timestamped folders older than `S3_DELETE_TIME_BUFFER` are removed on later syncs. The cost scales with the table's file count, not with what the sync changed. Warehouse source syncs use this path only as the fallback described below; other callers of `prepare_s3_files_for_querying` (for example data modeling) use it by default.
+- **Rotating slots** (every warehouse source sync). The table rotates through `<table>__query_a`, `__query_b` and `__query_c`. A sync picks the slot that stopped being the pointer longest ago, lists it, copies in the live files it lacks, removes the files that are no longer live, and returns it for the pointer flip. The diff is against the listing, so a missed sync or a crash mid-reconcile heals on the next pass. A populated slot is rewritten only when it stopped being the pointer at least `S3_DELETE_TIME_BUFFER` ago; with three slots that instant is one whole sync interval before the current slot took over, so a table synced more often than the buffer still takes the incremental path. Every pointer move is recorded in `sync_type_config["query_folder_state"]` (the active folder, the job that published it, when each slot stopped being the pointer, and since when the record is contiguous). A move the record missed (a crash between the pointer write and the record, or a schema reset) restarts the record, and until it is older than the buffer only an empty slot is used; when no slot is safe the sync falls back to a fresh timestamped folder. A table's first syncs on the slots fill the empty slots in full, and reconciliation takes over from there. The age-based cleanup still removes the timestamped folders a table used before it moved onto the slots, and it never matches the slot names. DuckLake registration tells generations on a reused slot name apart by the job that published them, read from the same record.
## How to clean up orphaned S3 data
diff --git a/products/warehouse_sources/backend/temporal/data_imports/pipelines/common/load.py b/products/warehouse_sources/backend/temporal/data_imports/pipelines/common/load.py
index 4c7ce55e27ee..8cd2fd575c74 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/pipelines/common/load.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/pipelines/common/load.py
@@ -30,11 +30,7 @@ from products.warehouse_sources.backend.temporal.data_imports.pipelines.pipeline
set_initial_sync_complete,
)
from products.warehouse_sources.backend.temporal.data_imports.query_folder_state import QueryFolderPointerHistory
-from products.warehouse_sources.backend.temporal.data_imports.schema_flags import is_schema_flag_enabled
-from products.warehouse_sources.backend.temporal.data_imports.util import (
- DOUBLE_BUFFERED_QUERY_FOLDERS_FLAG,
- prepare_s3_files_for_querying,
-)
+from products.warehouse_sources.backend.temporal.data_imports.util import prepare_s3_files_for_querying
from products.warehouse_sources.backend.types import ExternalDataSourceType
if TYPE_CHECKING:
@@ -348,15 +344,10 @@ async def _publish_queryable_files(
existing_queryable_folder = await database_sync_to_async_pool(_own_queryable_folder)()
- double_buffer = await database_sync_to_async_pool(is_schema_flag_enabled)(
- schema, DOUBLE_BUFFERED_QUERY_FOLDERS_FLAG
+ sync_type_config = await database_sync_to_async_pool(_stored_sync_type_config)(schema.id, job.team_id)
+ pointer_history = QueryFolderPointerHistory.from_config(
+ sync_type_config, f"{NamingConvention.normalize_identifier(resource_name)}__query"
)
- pointer_history = None
- if double_buffer:
- sync_type_config = await database_sync_to_async_pool(_stored_sync_type_config)(schema.id, job.team_id)
- pointer_history = QueryFolderPointerHistory.from_config(
- sync_type_config, f"{NamingConvention.normalize_identifier(resource_name)}__query"
- )
# File URIs are listed after delta maintenance so the queryable folder serves the compacted
# layout rather than the pre-compaction small files.
@@ -371,7 +362,7 @@ async def _publish_queryable_files(
existing_queryable_folder=existing_queryable_folder,
logger=logger,
refresh_file_uris=delta_table_ref.get_file_uris,
- double_buffer=double_buffer,
+ double_buffer=True,
pointer_history=pointer_history,
)
return folder
diff --git a/products/warehouse_sources/backend/temporal/data_imports/pipelines/common/test/test_load.py b/products/warehouse_sources/backend/temporal/data_imports/pipelines/common/test/test_load.py
index f63cbdb66a5b..329a323713ec 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/pipelines/common/test/test_load.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/pipelines/common/test/test_load.py
@@ -70,7 +70,6 @@ async def _run_post_load(
*,
cdc_write_mode: str | None = None,
resource: Optional[MagicMock] = None,
- double_buffer_enabled: bool = False,
stored_sync_type_config: dict | None = None,
) -> tuple[AsyncMock, AsyncMock]:
job = MagicMock()
@@ -83,7 +82,6 @@ async def _run_post_load(
with (
patch(f"{_LOAD_MODULE}.prepare_s3_files_for_querying", prepare_s3),
patch(f"{_LOAD_MODULE}.own_linked_table", lambda schema, _pipeline: schema.table),
- patch(f"{_LOAD_MODULE}.is_schema_flag_enabled", MagicMock(return_value=double_buffer_enabled)),
patch(f"{_LOAD_MODULE}._stored_sync_type_config", MagicMock(return_value=stored_sync_type_config)),
patch(f"{_LOAD_MODULE}.notify_revenue_analytics_that_sync_has_completed", AsyncMock()),
patch(f"{_LOAD_MODULE}.sync_revenue_analytics_views", MagicMock()),
@@ -174,7 +172,7 @@ class TestRunPostLoadDeltaMaintenance:
assert prepare_s3.await_args.args[2] == post_maintenance_uris
-class TestPublishQueryableFilesDoubleBufferRollout:
+class TestPublishQueryableFilesDoubleBuffer:
_STATE = {
"query_folder_state": {
"orders__query": {
@@ -196,33 +194,26 @@ class TestPublishQueryableFilesDoubleBufferRollout:
@parameterized.expand(
[
- # The flag is the rollback switch: off must reach the timestamped-folder path even when a
- # pointer record is stored, or turning it off after a bad rollout would change nothing.
- ("flag_off", False, _STATE, False, None),
- ("flag_on_with_record", True, _STATE, True, _HISTORY),
- ("flag_on_no_record", True, None, True, None),
+ ("with_record", _STATE, _HISTORY),
+ ("no_record", None, None),
]
)
@pytest.mark.asyncio
- async def test_passes_the_flag_and_the_pointer_history_to_the_publish_step(
+ async def test_passes_double_buffering_and_the_pointer_history_to_the_publish_step(
self,
_name: str,
- flag_enabled: bool,
stored_config: dict | None,
- expected_double_buffer: bool,
expected_history: QueryFolderPointerHistory | None,
) -> None:
schema = _make_schema(is_cdc=False)
schema.table.queryable_folder = "orders__query_a"
- _, prepare_s3 = await _run_post_load(
- schema, _make_helper(), double_buffer_enabled=flag_enabled, stored_sync_type_config=stored_config
- )
+ _, prepare_s3 = await _run_post_load(schema, _make_helper(), stored_sync_type_config=stored_config)
prepare_s3.assert_awaited_once()
assert prepare_s3.await_args is not None
assert prepare_s3.await_args.kwargs["existing_queryable_folder"] == "orders__query_a"
- assert prepare_s3.await_args.kwargs["double_buffer"] is expected_double_buffer
+ assert prepare_s3.await_args.kwargs["double_buffer"] is True
assert prepare_s3.await_args.kwargs["pointer_history"] == expected_history
diff --git a/products/warehouse_sources/backend/temporal/data_imports/pipelines/core/repartition_controller.py b/products/warehouse_sources/backend/temporal/data_imports/pipelines/core/repartition_controller.py
index 086c107565f9..e9e5f92f2b9c 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/pipelines/core/repartition_controller.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/pipelines/core/repartition_controller.py
@@ -9,7 +9,6 @@ schema. The next run's pre-extraction activity performs the rewrite (see `repart
from __future__ import annotations
import asyncio
-from collections.abc import Mapping
from typing import TYPE_CHECKING, Any, Literal
from django.conf import settings
@@ -43,11 +42,9 @@ from products.warehouse_sources.backend.temporal.data_imports.schema_flags impor
if TYPE_CHECKING:
from products.warehouse_sources.backend.models.external_data_source import ExternalDataSource
-WAREHOUSE_AUTO_REPARTITION_FLAG = "data-warehouse-auto-repartition"
-WAREHOUSE_AUTO_COARSEN_FLAG = "data-warehouse-auto-coarsen"
-# Gates pausing a schema's imports while a multi-budget rewrite converges. Separate from the
-# repartition flag, and off by default: repartitioning a table costs us worker time, pausing its
-# imports costs the customer freshness, so the second is not a decision the first should make.
+# Gates pausing a schema's imports while a multi-budget rewrite converges. Off by default:
+# repartitioning a table costs us worker time, pausing its imports costs the customer freshness, so
+# the second is not a decision the first should make.
WAREHOUSE_REPARTITION_HOLD_FLAG = "data-warehouse-repartition-hold"
# Coarsening gates. The two directions deliberately don't meet: a table is split finer above the budget
@@ -111,57 +108,18 @@ def repartition_oom_window_days() -> int:
return int(getattr(settings, "DATA_WAREHOUSE_REPARTITION_OOM_WINDOW_DAYS", 7))
-def is_auto_repartition_enabled(schema: ExternalDataSchema) -> bool:
- return is_schema_flag_enabled(schema, WAREHOUSE_AUTO_REPARTITION_FLAG)
-
-
-def is_auto_coarsen_enabled(schema: ExternalDataSchema) -> bool:
- return is_schema_flag_enabled(schema, WAREHOUSE_AUTO_COARSEN_FLAG)
-
-
-def needs_pre_extraction_detection(schema: ExternalDataSchema, enabled: bool) -> bool:
+def needs_pre_extraction_detection(schema: ExternalDataSchema) -> bool:
"""Whether to read the live on-disk partition sizes to decide if a repartition is needed.
We deliberately do NOT gate on the recorded `max_partition_bytes`. That value is only refreshed by
post-load detection, so for a table whose merge OOMs before post-load it goes stale and can sit far
below the true partition size — precisely the tables this path exists to rescue (e.g. a partition
that has since grown to many GB while the recorded value still reads a few hundred MB). Instead,
- whenever the rollout flag is on (a targeted set of schemas) and the table isn't CDC-excluded, we
- read the live partition sizes from the Delta log each run and let `maybe_flag_for_repartition` judge
- against the real, current size. The cost is one metadata-only Delta-log read per sync, bounded to
- flagged schemas; a disabled flag still short-circuits to a zero-I/O no-op.
-
- A table nominated for coarsening is measured whether or not the rollout flag covers it, since the
- nomination is the operator asking for exactly this measurement. CDC stays excluded either way.
- """
- if schema.sync_type == ExternalDataSchema.SyncType.CDC:
- return False
- if schema.coarsen_requested is not None:
- return True
- return enabled
-
-
-def is_pending_repartition_released_by_flag(
- schema: ExternalDataSchema, pending: Mapping[str, object], *, enabled: bool | None = None
-) -> bool:
- """Whether a queued rewrite's own rollout flag has since been disabled, releasing it as a no-op.
-
- Mirrors `_maybe_repartition_table`'s 'release' branch in `repartition_table.py` exactly: each
- auto-staged trigger family answers to the flag that staged it (the flag is the only lever support
- has to release such a table), and any other reason fails open because operator-staged work (admin,
- a staged swap) must never dead-end on a rollout flag. Shared so `repartition_activity_has_work`
- agrees with the activity's own answer instead of scheduling a round trip the activity would just
- skip.
-
- `enabled` lets a caller that already evaluated `WAREHOUSE_AUTO_REPARTITION_FLAG` this run thread
- the result through instead of paying for a second evaluation.
+ whenever the table isn't CDC-excluded, we read the live partition sizes from the Delta log each run
+ and let `maybe_flag_for_repartition` judge against the real, current size. The cost is one
+ metadata-only Delta-log read per sync.
"""
- reason = pending.get("trigger_reason")
- if reason in ("proactive_threshold", "oom_history"):
- return not (enabled if enabled is not None else is_auto_repartition_enabled(schema))
- if reason == "coarsening":
- return not is_auto_coarsen_enabled(schema)
- return False
+ return schema.sync_type != ExternalDataSchema.SyncType.CDC
def repartition_activity_has_work(schema: ExternalDataSchema) -> bool:
@@ -169,26 +127,14 @@ def repartition_activity_has_work(schema: ExternalDataSchema) -> bool:
The workflow uses this to skip scheduling the activity, so it must say True whenever the activity
itself would go past its own fast no-op path: a queued rewrite or staged swap to drive, or a table
- the rollout flag (or a coarsening nomination) wants measured on disk. A pending corruption revive
- makes the activity stand down before any of that, so it is a no-op here too. The flag is only
- evaluated when nothing is queued, which is the one case the activity's answer depends on it.
-
- A queued rewrite whose own trigger flag has since been disabled is also a no-op: the activity's
- fast path stands it down without doing any work (see `is_pending_repartition_released_by_flag`), so
- scheduling the activity for it would just pay a full round trip to log and return.
+ that needs measuring on disk. A pending corruption revive makes the activity stand down before any
+ of that, so it is a no-op here too.
"""
if schema.delta_revive_required is not None:
return False
- pending = schema.repartition_pending
- swap = schema.repartition_swap
- if swap is not None:
+ if schema.repartition_swap is not None or schema.repartition_pending is not None:
return True
- if pending is not None:
- enabled = is_auto_repartition_enabled(schema)
- if is_pending_repartition_released_by_flag(schema, pending, enabled=enabled):
- return needs_pre_extraction_detection(schema, enabled)
- return True
- return needs_pre_extraction_detection(schema, is_auto_repartition_enabled(schema))
+ return needs_pre_extraction_detection(schema)
def is_repartition_hold_enabled(schema: ExternalDataSchema) -> bool:
@@ -301,8 +247,8 @@ async def maybe_flag_for_coarsening(
check is `select_coarsen_target`, which measures the live layout and refuses any target that would
not fit the budget. Nothing overrides that, so a nomination can only ever be a no-op.
- Ordered cheapest first — in-memory shape gates, then the in-memory selector, then the database, and
- the feature flag (a Team fetch plus a PostHog API call) dead last. Post-load detection runs this
+ Ordered cheapest first — in-memory shape gates, then the in-memory selector, then the database.
+ Post-load detection runs this
for every within-budget table on every sync, so anything before the selector is fleet-wide cost,
and most tables that pass the shape gates sit at the coarsest tier where the selector refuses.
@@ -371,16 +317,6 @@ async def maybe_flag_for_coarsening(
if await asyncio.to_thread(ExternalDataSchemaOOMEvent.blocks_coarsening, schema, days=COARSEN_OOM_FREE_DAYS):
return _decline("oom_within_free_window")
- if not await asyncio.to_thread(is_auto_coarsen_enabled, schema):
- await logger.adebug(
- f"repartition: table is over-fragmented but coarsening is disabled by feature flag "
- f"schema_id={schema.id} max_partition_bytes={max_bytes} partition_count={measured_partitions}",
- schema_id=str(schema.id),
- max_partition_bytes=max_bytes,
- partition_count=measured_partitions,
- )
- return _decline("flag_disabled")
-
# Distinct reason for a nominated rewrite, the same way an admin-staged one is distinguishable, so
# the backlog pass can be tracked separately from what the controller does on its own.
trigger_reason = "coarsening_requested" if requested is not None else "coarsening"
@@ -425,18 +361,11 @@ async def maybe_flag_for_repartition(
job: ExternalDataJob,
delta_table: deltalake.DeltaTable,
logger: FilteringBoundLogger,
- *,
- enabled: bool | None = None,
) -> None:
"""Measure partition sizes and, if over budget, record a `repartition_pending` target.
- Always records `max_partition_bytes` for observability (even when the controller is disabled or in
- cooldown). Setting the pending target is gated by the feature flag; the rewrite itself happens on
- the next run. Never raises — detection must not break post-load.
-
- Pass `enabled` when the caller has already evaluated the rollout flag for this schema (each
- evaluation is a `Team.objects.get()` plus a PostHog API call) to avoid re-evaluating it here; when
- omitted it is evaluated lazily, only once the table is confirmed over budget.
+ Always records `max_partition_bytes` for observability (even when the table is in cooldown). The
+ rewrite itself happens on the next run. Never raises — detection must not break post-load.
"""
try:
# A table pending a corruption revive must heal before it's rewritten — flagging it here would
@@ -538,21 +467,6 @@ async def maybe_flag_for_repartition(
max_partition_bytes=max_bytes,
)
- if enabled is None:
- enabled = await asyncio.to_thread(is_auto_repartition_enabled, schema)
- if not enabled:
- await logger.adebug(
- f"repartition: needs repartition but skipped, controller disabled by feature flag "
- f"schema_id={schema.id} trigger_reason={trigger_reason} max_partition_bytes={max_bytes} "
- f"budget_bytes={budget} recent_oom_count={oom_count}",
- schema_id=str(schema.id),
- trigger_reason=trigger_reason,
- max_partition_bytes=max_bytes,
- budget_bytes=budget,
- recent_oom_count=oom_count,
- )
- return
-
if schema.repartition_pending is not None:
await logger.adebug(
f"repartition: needs repartition (trigger_reason={trigger_reason}) but already queued for the next "
diff --git a/products/warehouse_sources/backend/temporal/data_imports/pipelines/core/test_repartition_controller.py b/products/warehouse_sources/backend/temporal/data_imports/pipelines/core/test_repartition_controller.py
index e7dad5a98747..a95d642974d3 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/pipelines/core/test_repartition_controller.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/pipelines/core/test_repartition_controller.py
@@ -105,7 +105,6 @@ class TestRepartitionDetection:
delta = _write_partitioned_delta(f"{d}/t", ["0", "0", "1", "1"])
with (
patch.object(ctrl, "target_partition_bytes", return_value=1),
- patch.object(ctrl, "is_auto_repartition_enabled", return_value=True),
patch.object(ctrl, "capture_repartition_event") as capture,
):
self._detect(team, schema, delta)
@@ -152,7 +151,6 @@ class TestRepartitionDetection:
delta = _write_unpartitioned_delta(f"{d}/t")
with (
patch.object(ctrl, "target_partition_bytes", return_value=1),
- patch.object(ctrl, "is_auto_repartition_enabled", return_value=True),
patch.object(ctrl, "capture_repartition_event") as capture,
):
self._detect(team, schema, delta)
@@ -170,21 +168,6 @@ class TestRepartitionDetection:
delta = _write_partitioned_delta(f"{d}/t", ["0", "1"])
with (
patch.object(ctrl, "target_partition_bytes", return_value=10**12),
- patch.object(ctrl, "is_auto_repartition_enabled", return_value=True),
- ):
- self._detect(team, schema, delta)
-
- schema.refresh_from_db()
- assert schema.max_partition_bytes is not None
- assert schema.repartition_pending is None
-
- def test_disabled_flag_records_size_but_does_not_flag(self, team):
- schema = _make_schema(team, {"partitioning_enabled": True, "partition_mode": "md5", "partition_count": 2})
- with tempfile.TemporaryDirectory() as d:
- delta = _write_partitioned_delta(f"{d}/t", ["0", "1"])
- with (
- patch.object(ctrl, "target_partition_bytes", return_value=1),
- patch.object(ctrl, "is_auto_repartition_enabled", return_value=False),
):
self._detect(team, schema, delta)
@@ -208,7 +191,6 @@ class TestRepartitionDetection:
delta = _write_partitioned_delta(f"{d}/t", ["0", "1"])
with (
patch.object(ctrl, "target_partition_bytes", return_value=1),
- patch.object(ctrl, "is_auto_repartition_enabled", return_value=True),
):
self._detect(team, schema, delta)
@@ -248,7 +230,6 @@ class TestRepartitionDetection:
delta = _write_unpartitioned_delta(f"{d}/u")
with (
patch.object(ctrl, "target_partition_bytes", return_value=1),
- patch.object(ctrl, "is_auto_repartition_enabled", return_value=True),
patch.object(ctrl, "capture_repartition_event") as capture,
patch.object(ctrl, "capture_exception") as mock_capture_exception,
):
@@ -271,7 +252,6 @@ class TestRepartitionDetection:
delta = _write_unpartitioned_delta(f"{d}/u")
with (
patch.object(ctrl, "target_partition_bytes", return_value=1),
- patch.object(ctrl, "is_auto_repartition_enabled", return_value=True),
patch.object(ctrl, "capture_repartition_event") as capture,
):
self._detect(team, schema, delta)
@@ -293,7 +273,6 @@ class TestRepartitionDetection:
delta = _write_unpartitioned_delta(f"{d}/u")
with (
patch.object(ctrl, "target_partition_bytes", return_value=1),
- patch.object(ctrl, "is_auto_repartition_enabled", return_value=True),
patch.object(ctrl, "capture_repartition_event"),
):
self._detect(team, schema, delta)
@@ -304,11 +283,11 @@ class TestRepartitionDetection:
assert schema.repartition_pending["partition_keys"] == ["id"]
-class TestIsAutoRepartitionEnabled:
+class TestIsRepartitionHoldEnabled:
def test_retries_once_on_transient_db_connection_drop(self, team):
# The Team lookup runs on a long-lived Temporal worker thread; a pooler-dropped connection
# raises OperationalError on first use. Without a retry this propagates out of
- # is_auto_repartition_enabled uncaught (it's outside the function's Team.DoesNotExist/
+ # is_repartition_hold_enabled uncaught (it's outside the function's Team.DoesNotExist/
# feature_enabled try blocks) instead of resolving the flag.
schema = _make_schema(team, {})
mock_queryset = MagicMock()
@@ -318,14 +297,14 @@ class TestIsAutoRepartitionEnabled:
patch("posthog.models.Team.objects.only", return_value=mock_queryset),
patch.object(ctrl.posthoganalytics, "feature_enabled", return_value=True),
):
- assert ctrl.is_auto_repartition_enabled(schema) is True
+ assert ctrl.is_repartition_hold_enabled(schema) is True
assert mock_queryset.get.call_count == 2
def test_returns_false_when_db_connection_stays_down(self, team):
- # If the connection is still down on the retry, is_auto_repartition_enabled must not raise —
- # repartition_table.py calls it with no enclosing try/except, so an uncaught OperationalError
- # here crashes the whole activity instead of just leaving the flag resolved as disabled.
+ # If the connection is still down on the retry, the flag helper must not raise — an uncaught
+ # OperationalError here crashes the whole activity instead of just leaving the flag resolved
+ # as disabled.
schema = _make_schema(team, {})
mock_queryset = MagicMock()
mock_queryset.get.side_effect = OperationalError("server closed the connection unexpectedly")
@@ -334,7 +313,7 @@ class TestIsAutoRepartitionEnabled:
patch("posthog.models.Team.objects.only", return_value=mock_queryset),
patch.object(schema_flags, "capture_exception") as mock_capture_exception,
):
- assert ctrl.is_auto_repartition_enabled(schema) is False
+ assert ctrl.is_repartition_hold_enabled(schema) is False
assert mock_queryset.get.call_count == 2
mock_capture_exception.assert_called_once()
@@ -364,7 +343,6 @@ class TestRepartitionOOMHistoryTrigger:
# The split floor is exercised by its own test below; neutralize it here so this one
# fails only if the OOM trigger itself stops working.
patch.object(ctrl, "min_splittable_partition_bytes", return_value=1),
- patch.object(ctrl, "is_auto_repartition_enabled", return_value=True),
patch.object(ctrl, "capture_repartition_event"),
):
self._detect(team, schema, delta)
@@ -401,7 +379,6 @@ class TestRepartitionOOMHistoryTrigger:
# Small enough that the tiny-partition guard doesn't mask the revive guard under test.
patch.object(ctrl, "target_partition_bytes", return_value=10_000),
patch.object(ctrl, "repartition_oom_threshold", return_value=3),
- patch.object(ctrl, "is_auto_repartition_enabled", return_value=True),
patch.object(ctrl, "capture_repartition_event"),
):
self._detect(team, schema, delta)
@@ -430,7 +407,6 @@ class TestRepartitionOOMHistoryTrigger:
ctrl, "target_partition_bytes", return_value=10**12
), # partitions orders of magnitude under
patch.object(ctrl, "repartition_oom_threshold", return_value=3),
- patch.object(ctrl, "is_auto_repartition_enabled", return_value=True),
patch.object(ctrl, "capture_repartition_event") as capture,
):
self._detect(team, schema, delta)
@@ -459,14 +435,12 @@ class TestCoarsenTrigger:
)
def _detect_over_fragmented(
- self, team, schema: ExternalDataSchema, *, coarsen_enabled: bool = True, buckets: list[str] | None = None
+ self, team, schema: ExternalDataSchema, *, buckets: list[str] | None = None
) -> MagicMock:
with tempfile.TemporaryDirectory() as d:
delta = _write_partitioned_delta(f"{d}/t", buckets or [str(bucket) for bucket in range(16)])
with (
patch.object(ctrl, "target_partition_bytes", return_value=10**12),
- patch.object(ctrl, "is_auto_repartition_enabled", return_value=True),
- patch.object(ctrl, "is_auto_coarsen_enabled", return_value=coarsen_enabled),
patch.object(ctrl, "capture_repartition_event") as capture,
):
self._detect(team, schema, delta)
@@ -510,8 +484,6 @@ class TestCoarsenTrigger:
# A layout that was just rewritten hasn't had a chance to prove itself; undoing it within
# the day is how the two directions would start handing the table back and forth.
"fresh_layout",
- # Enrolment is per-schema, like the finer path's.
- "flag_disabled",
],
)
def test_does_not_coarsen_when_a_guard_applies(self, team, case):
@@ -521,7 +493,7 @@ class TestCoarsenTrigger:
if case == "recent_oom":
self._record_oom(schema)
- self._detect_over_fragmented(team, schema, coarsen_enabled=case != "flag_disabled")
+ self._detect_over_fragmented(team, schema)
assert schema.repartition_pending is None
@@ -581,7 +553,6 @@ class TestCoarsenTrigger:
[
("unexplained_oom", "oom_within_free_window"),
("fresh_layout", "layout_too_young"),
- ("flag_disabled", "flag_disabled"),
],
)
def test_declining_to_coarsen_records_which_gate_stopped_it(self, team, case, expected_reason):
@@ -594,18 +565,18 @@ class TestCoarsenTrigger:
self._record_oom(schema, days_ago=10)
with patch.object(ctrl, "DELTA_COARSEN_DECLINE_TOTAL") as decline_metric:
- self._detect_over_fragmented(team, schema, coarsen_enabled=case != "flag_disabled")
+ self._detect_over_fragmented(team, schema)
assert decline_metric.labels.call_args.kwargs == {"reason": expected_reason}
def test_operator_nomination_overrides_the_policy_gates(self, team):
# The backlog of already-over-split tables is blocked by the OOM-free gate, because the signal
# that over-split them keeps firing. A nomination is how an operator gets past that, so it has
- # to work with OOM history present, the flag off, and a layout younger than the age gate.
+ # to work with OOM history present and a layout younger than the age gate.
schema = self._fragmented_schema(team, last_repartition_at=_days_ago_iso(0), coarsen_requested=_NOMINATION)
self._record_oom(schema)
- self._detect_over_fragmented(team, schema, coarsen_enabled=False)
+ self._detect_over_fragmented(team, schema)
pending = schema.repartition_pending
assert pending is not None
@@ -620,7 +591,7 @@ class TestCoarsenTrigger:
schema = self._fragmented_schema(team, coarsen_requested=_NOMINATION)
with patch.object(ExternalDataSchema, "set_repartition_pending", side_effect=RuntimeError("pooler dropped")):
- self._detect_over_fragmented(team, schema, coarsen_enabled=False)
+ self._detect_over_fragmented(team, schema)
assert schema.repartition_pending is None
assert schema.coarsen_requested is not None, "a failed staging must not consume the nomination"
@@ -638,7 +609,7 @@ class TestCoarsenTrigger:
)
buckets = [f"2024-01-01T{hour:02d}" for hour in range(15)] + ["1970-01"]
- self._detect_over_fragmented(team, schema, coarsen_enabled=False, buckets=buckets)
+ self._detect_over_fragmented(team, schema, buckets=buckets)
assert schema.repartition_pending is None
assert schema.coarsen_requested is None
@@ -660,31 +631,27 @@ class TestRepartitionActivity:
def _run(self, inputs: RepartitionActivityInputs, repartition_mock: AsyncMock):
# Mock HeartbeaterSync (no real heartbeat thread / activity context needed) and the primitive,
- # so these exercise the activity's decision + bookkeeping, not the rewrite itself. The rollout
- # flag is forced on because it now gates the queued rewrite as well as detection, so every
- # caller of this helper (all of which stage a pending target and expect it to be acted on)
- # would otherwise be released by the gate before reaching the bookkeeping under test.
+ # so these exercise the activity's decision + bookkeeping, not the rewrite itself.
with (
patch.object(repartition_table, "HeartbeaterSync"),
patch.object(repartition_table, "repartition_table_in_place", new=repartition_mock),
patch.object(repartition_table, "capture_repartition_event") as capture,
- patch.object(repartition_table, "is_auto_repartition_enabled", return_value=True),
):
# ActivityEnvironment.run is synchronous for a sync activity — call it directly.
ActivityEnvironment().run(maybe_repartition_table_activity, inputs)
return capture
- def test_noop_when_flag_disabled(self, team):
- # Healthy no-op: the rollout flag being off short-circuits the gate before any on-disk I/O — no
- # job fetch, no delta read, no detection, no rewrite — regardless of any recorded size. Guards
- # the gate that keeps unflagged syncs free of the extra pre-extraction work.
+ def test_noop_for_cdc_table(self, team):
+ # Healthy no-op: a CDC table short-circuits the gate before any on-disk I/O — no job fetch, no
+ # delta read, no detection, no rewrite — regardless of any recorded size.
schema = _make_schema(team, {"max_partition_bytes": 5})
+ schema.sync_type = ExternalDataSchema.SyncType.CDC
+ schema.save()
mocked = AsyncMock()
with (
patch.object(repartition_table, "HeartbeaterSync"),
patch.object(repartition_table, "repartition_table_in_place", new=mocked),
patch.object(repartition_table, "capture_repartition_event"),
- patch.object(repartition_table, "is_auto_repartition_enabled", return_value=False),
patch.object(repartition_table, "maybe_flag_for_repartition") as flag,
):
ActivityEnvironment().run(maybe_repartition_table_activity, self._inputs(team, schema))
@@ -714,7 +681,6 @@ class TestRepartitionActivity:
patch.object(repartition_table, "HeartbeaterSync"),
patch.object(repartition_table, "repartition_table_in_place", new=mocked),
patch.object(repartition_table, "capture_repartition_event"),
- patch.object(repartition_table, "is_auto_repartition_enabled", return_value=True),
patch.object(repartition_table, "maybe_flag_for_repartition") as flag,
):
ActivityEnvironment().run(maybe_repartition_table_activity, self._inputs(team, schema))
@@ -723,7 +689,7 @@ class TestRepartitionActivity:
@pytest.mark.parametrize("recorded_max_partition_bytes", [None, 5])
def test_pre_extraction_flags_over_budget_live_table(self, team, recorded_max_partition_bytes):
- # Nothing queued, flag on: the activity reads the LIVE on-disk size and repartitions when it's
+ # Nothing queued: the activity reads the LIVE on-disk size and repartitions when it's
# over budget. The `recorded_max_partition_bytes=5` case is the fix's core regression: a stale,
# within-budget recorded value (from a merge that OOMed before it could refresh) must NOT
# short-circuit detection — the gate now trusts the live size, not the recorded one.
@@ -745,9 +711,6 @@ class TestRepartitionActivity:
patch.object(repartition_table, "capture_repartition_event") as capture,
patch.object(repartition_table.DeltaTableRef, "get_delta_table", new=AsyncMock(return_value=delta)),
patch.object(ctrl, "target_partition_bytes", return_value=1),
- # The activity evaluates the rollout flag once and threads the verdict into detection,
- # so patch the binding the activity reads from (not the controller's).
- patch.object(repartition_table, "is_auto_repartition_enabled", return_value=True),
patch.object(ctrl, "capture_repartition_event"),
):
ActivityEnvironment().run(maybe_repartition_table_activity, self._inputs(team, schema))
@@ -1128,10 +1091,6 @@ class TestRepartitionActivity:
patch.object(repartition_table, "repartition_table_in_place", new=rewrite),
patch.object(repartition_table, "capture_repartition_event") as capture,
patch.object(repartition_table, "capture_exception") as capture_exception,
- patch.object(repartition_table, "is_auto_repartition_enabled", return_value=True),
- # A coarsening trigger answers to the coarsen flag, not the repartition one; without this the
- # activity releases the queued rewrite before reaching the give-up.
- patch.object(repartition_table, "is_auto_coarsen_enabled", return_value=True),
):
ActivityEnvironment().run(maybe_repartition_table_activity, self._inputs(team, schema))
@@ -1167,7 +1126,6 @@ class TestRepartitionActivity:
patch.object(repartition_table, "HeartbeaterSync"),
patch.object(repartition_table, "repartition_table_in_place", new=mocked),
patch.object(repartition_table, "capture_repartition_event") as capture,
- patch.object(repartition_table, "is_auto_repartition_enabled", return_value=True),
):
with pytest.raises((asyncio.CancelledError, CancelledError)):
ActivityEnvironment().run(maybe_repartition_table_activity, self._inputs(team, schema))
@@ -1276,7 +1234,6 @@ class TestRepartitionActivity:
patch.object(repartition_table, "repartition_table_in_place", new=mocked),
patch.object(repartition_table, "capture_repartition_event") as capture,
patch.object(repartition_table, "_still_claimant", return_value=still_claimant),
- patch.object(repartition_table, "is_auto_repartition_enabled", return_value=True),
):
ActivityEnvironment().run(maybe_repartition_table_activity, self._inputs(team, schema))
assert "warehouse_repartition_failed" not in [c.args[0] for c in capture.call_args_list]
@@ -1327,7 +1284,7 @@ class TestRepartitionActivity:
mock_queryset.get.side_effect = [OperationalError("server closed the connection unexpectedly"), schema]
with (
patch.object(ExternalDataSchema.objects, "select_related", return_value=mock_queryset),
- patch.object(repartition_table, "is_auto_repartition_enabled", return_value=False),
+ patch.object(repartition_table, "needs_pre_extraction_detection", return_value=False),
patch.object(repartition_table, "capture_repartition_event"),
):
ActivityEnvironment().run(maybe_repartition_table_activity, self._inputs(team, schema))
@@ -1354,7 +1311,6 @@ class TestRepartitionActivity:
patch.object(repartition_table, "HeartbeaterSync"),
patch.object(repartition_table, "repartition_table_in_place", new=mocked),
patch.object(repartition_table, "capture_repartition_event"),
- patch.object(repartition_table, "is_auto_repartition_enabled", return_value=True),
):
ActivityEnvironment().run(
maybe_repartition_table_activity,
diff --git a/products/warehouse_sources/backend/temporal/data_imports/pipelines/pipeline_v3/coalescing.py b/products/warehouse_sources/backend/temporal/data_imports/pipelines/pipeline_v3/coalescing.py
index b96e0f88c152..4b2e2dbc991b 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/pipelines/pipeline_v3/coalescing.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/pipelines/pipeline_v3/coalescing.py
@@ -122,7 +122,6 @@ class CoalesceCaps:
max_batches: int
max_rows: int
max_bytes: int
- across_runs: bool
@classmethod
def from_settings(cls) -> CoalesceCaps:
@@ -130,7 +129,6 @@ class CoalesceCaps:
max_batches=settings.DATA_WAREHOUSE_V3_COALESCE_MAX_BATCHES,
max_rows=settings.DATA_WAREHOUSE_V3_COALESCE_MAX_ROWS,
max_bytes=settings.DATA_WAREHOUSE_V3_COALESCE_MAX_BYTES,
- across_runs=settings.DATA_WAREHOUSE_V3_COALESCE_ACROSS_RUNS,
)
@@ -174,8 +172,6 @@ def join_violation(current: Sequence[CoalesceMember], candidate: CoalesceMember)
def extends_set(current: Sequence[CoalesceMember], candidate: CoalesceMember, caps: CoalesceCaps) -> bool:
if join_violation(current, candidate) is not None:
return False
- if candidate.run_uuid != current[-1].run_uuid and not caps.across_runs:
- return False
if len(current) >= caps.max_batches:
return False
rows = sum(member.row_count for member in current) + candidate.row_count
diff --git a/products/warehouse_sources/backend/temporal/data_imports/pipelines/pipeline_v3/postgres_queue/test_consumer.py b/products/warehouse_sources/backend/temporal/data_imports/pipelines/pipeline_v3/postgres_queue/test_consumer.py
index f070acff859d..0a4323ee6db9 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/pipelines/pipeline_v3/postgres_queue/test_consumer.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/pipelines/pipeline_v3/postgres_queue/test_consumer.py
@@ -3907,7 +3907,6 @@ class TestCoalesceGroup:
"first_sync_flag_splits",
],
)
- @override_settings(DATA_WAREHOUSE_V3_COALESCE_ACROSS_RUNS=True)
def test_consecutive_runs(self, second_run: dict[str, Any], expected: list[list[int]]):
first_sync_type = second_run.get("sync_type", "incremental")
batches = _run_batches(2, run_uuid="run-1", sync_type=first_sync_type) + _run_batches(
@@ -3915,12 +3914,6 @@ class TestCoalesceGroup:
)
assert self._sets(batches) == expected
- def test_cross_run_sets_can_be_switched_off(self):
- batches = _run_batches(2, run_uuid="run-1") + _run_batches(2, run_uuid="run-2", is_resume=True)
- with override_settings(DATA_WAREHOUSE_V3_COALESCE_ACROSS_RUNS=False):
- assert self._sets(batches) == [[0, 1], [0, 1]]
-
- @override_settings(DATA_WAREHOUSE_V3_COALESCE_ACROSS_RUNS=True)
def test_members_keep_the_claim_order_and_a_run_never_reappears_in_a_set(self):
# The claim query orders a group by (created_at, batch_index) and the loader takes that order
# one batch at a time; a set that reordered members, or folded a run back in after another
@@ -4055,7 +4048,6 @@ class TestProcessGroupCoalescing:
ids=["declined", "failed"],
)
@pytest.mark.asyncio
- @override_settings(DATA_WAREHOUSE_V3_COALESCE_ACROSS_RUNS=True)
async def test_a_set_that_cannot_load_falls_back_to_its_members(
self, error: Exception, expected_latest_attempt: int, expected_status_attempt: int
):
diff --git a/products/warehouse_sources/backend/temporal/data_imports/tests/e2e/test_end_to_end.py b/products/warehouse_sources/backend/temporal/data_imports/tests/e2e/test_end_to_end.py
index 3c3617b1fc4a..2e2ea8d816ce 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/tests/e2e/test_end_to_end.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/tests/e2e/test_end_to_end.py
@@ -574,7 +574,7 @@ async def _run(
assert table.queryable_folder is not None
assert table.credential_id is None
- query_folder_pattern = re.compile(r"^.+?\_\_query\_\d+_[0-9a-f]{8}$")
+ query_folder_pattern = re.compile(r"^.+?__query_[abc]$")
assert query_folder_pattern.match(table.queryable_folder)
return workflow_id, inputs
@@ -1118,7 +1118,7 @@ async def test_delta_wrapper_files(team, stripe_balance_transaction, mock_stripe
folder_path = await sync_to_async(latest_job.folder_path)()
s3_objects = await minio_client.list_objects_v2(
- Bucket=BUCKET_NAME, Prefix=f"{folder_path}/balance_transaction__query_{int(datetime_now.timestamp())}_"
+ Bucket=BUCKET_NAME, Prefix=f"{folder_path}/balance_transaction__query_a/"
)
assert len(s3_objects["Contents"]) != 0
@@ -2317,14 +2317,7 @@ async def test_in_place_repartition_to_finer_datetime_format(team, postgres_conf
)
await postgres_connection.commit()
- # The rollout flag gates the queued rewrite, not just detection, so a table whose repartition is
- # already pending is still released when the flag is off. Force it on for the run under test.
- with mock.patch(
- "products.warehouse_sources.backend.temporal.data_imports.workflow_activities."
- "repartition_table.is_auto_repartition_enabled",
- return_value=True,
- ):
- await _execute_run(str(uuid.uuid4()), inputs, [])
+ await _execute_run(str(uuid.uuid4()), inputs, [])
await _replay_v3_consumer(team_id=team.pk, schema_id=inputs.external_data_schema_id)
schema = await ExternalDataSchema.objects.aget(id=inputs.external_data_schema_id)
@@ -2351,21 +2344,6 @@ async def test_in_place_repartition_to_finer_datetime_format(team, postgres_conf
assert count_after.results[0][0] == 5
-_COARSEN_FLAGS_ON = (
- "products.warehouse_sources.backend.temporal.data_imports.workflow_activities.repartition_table"
- ".is_auto_repartition_enabled",
- "products.warehouse_sources.backend.temporal.data_imports.pipelines.core.repartition_controller"
- ".is_auto_coarsen_enabled",
- # `repartition_activity_has_work` (used by job creation to decide whether to schedule the
- # activity at all) calls the module-local `is_auto_repartition_enabled` binding inside
- # `repartition_controller`, a separate name from the one `repartition_table` imported for its
- # own use above. Patching only the latter leaves job creation seeing the real (disabled) flag,
- # so organic pre-extraction detection never gets scheduled and coarsening never runs.
- "products.warehouse_sources.backend.temporal.data_imports.pipelines.core.repartition_controller"
- ".is_auto_repartition_enabled",
-)
-
-
async def _seed_dated_rows(postgres_connection, postgres_config, table: str, timestamps: list[str]) -> None:
await postgres_connection.execute(
"CREATE TABLE IF NOT EXISTS {schema}.{table} (id uuid PRIMARY KEY, created_at timestamp)".format(
@@ -2456,13 +2434,8 @@ async def test_in_place_coarsening_merges_weekly_partitions_into_months(
assert len(ids_before) == len(timestamps)
# Coarsening evaluates on the next sync and, finding a layout that fits, rewrites in the same run.
- with (
- mock.patch(_COARSEN_FLAGS_ON[0], return_value=True),
- mock.patch(_COARSEN_FLAGS_ON[1], return_value=True),
- mock.patch(_COARSEN_FLAGS_ON[2], return_value=True),
- ):
- await _execute_run(str(uuid.uuid4()), inputs, [])
- await _replay_v3_consumer(team_id=team.pk, schema_id=inputs.external_data_schema_id)
+ await _execute_run(str(uuid.uuid4()), inputs, [])
+ await _replay_v3_consumer(team_id=team.pk, schema_id=inputs.external_data_schema_id)
schema = await ExternalDataSchema.objects.aget(id=inputs.external_data_schema_id)
assert schema.partition_format == "month", "the table should have been merged up to monthly partitions"
@@ -2476,13 +2449,8 @@ async def test_in_place_coarsening_merges_weekly_partitions_into_months(
assert await _row_ids(team, "postgres_test_coarsen_week") == ids_before
# And it must settle: a table just coarsened must not be split straight back on the next sync.
- with (
- mock.patch(_COARSEN_FLAGS_ON[0], return_value=True),
- mock.patch(_COARSEN_FLAGS_ON[1], return_value=True),
- mock.patch(_COARSEN_FLAGS_ON[2], return_value=True),
- ):
- await _execute_run(str(uuid.uuid4()), inputs, [])
- await _replay_v3_consumer(team_id=team.pk, schema_id=inputs.external_data_schema_id)
+ await _execute_run(str(uuid.uuid4()), inputs, [])
+ await _replay_v3_consumer(team_id=team.pk, schema_id=inputs.external_data_schema_id)
schema = await ExternalDataSchema.objects.aget(id=inputs.external_data_schema_id)
assert schema.partition_format == "month", "the layout should have settled rather than oscillating"
@@ -2517,9 +2485,8 @@ async def test_oom_history_does_not_split_a_table_with_tiny_partitions(
await _record_suspected_ooms(team, schema, 3) # enough to trip the OOM trigger on its own
- with mock.patch(_COARSEN_FLAGS_ON[0], return_value=True):
- await _execute_run(str(uuid.uuid4()), inputs, [])
- await _replay_v3_consumer(team_id=team.pk, schema_id=inputs.external_data_schema_id)
+ await _execute_run(str(uuid.uuid4()), inputs, [])
+ await _replay_v3_consumer(team_id=team.pk, schema_id=inputs.external_data_schema_id)
schema = await ExternalDataSchema.objects.aget(id=inputs.external_data_schema_id)
assert schema.partition_format == "week", "OOM history must not split a table whose partitions are already tiny"
@@ -2552,6 +2519,10 @@ async def test_operator_nomination_coarsens_a_table_the_automatic_path_refuses(
schema = await ExternalDataSchema.objects.aget(id=inputs.external_data_schema_id)
ids_before = await _row_ids(team, "postgres_test_nominated")
await _record_suspected_ooms(team, schema, 3)
+ # The first sync's post-load detection queued an automatic coarsening before any OOM history
+ # existed. Drop it, so the run below starts from the backlog's state: over-split, OOM history
+ # recorded, nothing queued.
+ await sync_to_async(schema.clear_repartition_pending)()
await sync_to_async(call_command)(
"stage_warehouse_coarsening", "--execute", f"--schema-id={schema.id}", "--requested-by=e2e"
@@ -2605,10 +2576,7 @@ async def test_in_place_coarsening_merges_hourly_partitions_up(
"attempts": 0,
}
)
- # The rollout flag gates the queued rewrite too (a pending repartition is released, not run, when
- # it's off), so force it on for the staging run that produces the over-split layout.
- with mock.patch(_COARSEN_FLAGS_ON[0], return_value=True):
- await _execute_run(str(uuid.uuid4()), inputs, [])
+ await _execute_run(str(uuid.uuid4()), inputs, [])
await _replay_v3_consumer(team_id=team.pk, schema_id=inputs.external_data_schema_id)
schema = await ExternalDataSchema.objects.aget(id=inputs.external_data_schema_id)
@@ -2618,13 +2586,8 @@ async def test_in_place_coarsening_merges_hourly_partitions_up(
ids_before = await _row_ids(team, "postgres_test_coarsen_hour")
await _backdate_last_repartition(schema, days=8)
- with (
- mock.patch(_COARSEN_FLAGS_ON[0], return_value=True),
- mock.patch(_COARSEN_FLAGS_ON[1], return_value=True),
- mock.patch(_COARSEN_FLAGS_ON[2], return_value=True),
- ):
- await _execute_run(str(uuid.uuid4()), inputs, [])
- await _replay_v3_consumer(team_id=team.pk, schema_id=inputs.external_data_schema_id)
+ await _execute_run(str(uuid.uuid4()), inputs, [])
+ await _replay_v3_consumer(team_id=team.pk, schema_id=inputs.external_data_schema_id)
schema = await ExternalDataSchema.objects.aget(id=inputs.external_data_schema_id)
assert schema.partition_format == "month", "hourly partitions should merge straight up to monthly"
@@ -2695,9 +2658,7 @@ async def test_in_place_coarsening_for_hashed_and_numerical_modes(
"attempts": 0,
}
)
- # Same as the datetime test: the rollout flag must be on for the staging rewrite to run at all.
- with mock.patch(_COARSEN_FLAGS_ON[0], return_value=True):
- await _execute_run(str(uuid.uuid4()), inputs, [])
+ await _execute_run(str(uuid.uuid4()), inputs, [])
await _replay_v3_consumer(team_id=team.pk, schema_id=inputs.external_data_schema_id)
schema = await ExternalDataSchema.objects.aget(id=inputs.external_data_schema_id)
@@ -2708,13 +2669,8 @@ async def test_in_place_coarsening_for_hashed_and_numerical_modes(
assert len(ids_before) == 320
await _backdate_last_repartition(schema, days=8)
- with (
- mock.patch(_COARSEN_FLAGS_ON[0], return_value=True),
- mock.patch(_COARSEN_FLAGS_ON[1], return_value=True),
- mock.patch(_COARSEN_FLAGS_ON[2], return_value=True),
- ):
- await _execute_run(str(uuid.uuid4()), inputs, [])
- await _replay_v3_consumer(team_id=team.pk, schema_id=inputs.external_data_schema_id)
+ await _execute_run(str(uuid.uuid4()), inputs, [])
+ await _replay_v3_consumer(team_id=team.pk, schema_id=inputs.external_data_schema_id)
schema = await ExternalDataSchema.objects.aget(id=inputs.external_data_schema_id)
for field, value in expected_after.items():
@@ -3761,7 +3717,7 @@ async def test_postgres_deleting_schemas_with_pre_synced_data(team, postgres_con
@pytest.mark.django_db(transaction=True)
@pytest.mark.asyncio
-async def test_timestamped_query_folder(team, stripe_balance_transaction, mock_stripe_client, minio_client):
+async def test_query_folder_slots_rotate(team, stripe_balance_transaction, mock_stripe_client, minio_client):
datetime_1 = datetime.now()
with time_machine.travel(datetime_1, tick=False):
workflow_id, inputs = await _run(
@@ -3779,118 +3735,41 @@ async def test_timestamped_query_folder(team, stripe_balance_transaction, mock_s
schema = await ExternalDataSchema.objects.aget(id=inputs.external_data_schema_id)
folder_path = await sync_to_async(schema.folder_path)()
- # Sync a second time 5 minutes later
+ async def _queryable_folder() -> str | None:
+ table = await sync_to_async(lambda: ExternalDataSchema.objects.get(id=schema.id).table)()
+ return table.queryable_folder if table else None
+
+ assert await _queryable_folder() == "balance_transaction__query_a"
+
+ # Each sync fills the next empty slot, so readers of the previous slot are never disturbed.
datetime_2 = datetime_1 + timedelta(minutes=5)
with time_machine.travel(datetime_2, tick=False):
await _execute_run(workflow_id, inputs, stripe_balance_transaction["data"])
await _replay_v3_consumer(team_id=team.pk, schema_id=inputs.external_data_schema_id)
+ assert await _queryable_folder() == "balance_transaction__query_b"
- # Check the query folders now - both sync folders should exist
- s3_objects_datetime_1 = await minio_client.list_objects_v2(
- Bucket=BUCKET_NAME, Prefix=f"{folder_path}/balance_transaction__query_{int(datetime_1.timestamp())}_"
- )
-
- s3_objects_datetime_2 = await minio_client.list_objects_v2(
- Bucket=BUCKET_NAME, Prefix=f"{folder_path}/balance_transaction__query_{int(datetime_2.timestamp())}_"
- )
-
- assert len(s3_objects_datetime_1["Contents"]) != 0
- assert len(s3_objects_datetime_2["Contents"]) != 0
-
- # Sync a third time 3 minutes later (still under 10 mins since the first sync)
- datetime_3 = datetime_2 + timedelta(minutes=3)
+ datetime_3 = datetime_2 + timedelta(minutes=5)
with time_machine.travel(datetime_3, tick=False):
await _execute_run(workflow_id, inputs, stripe_balance_transaction["data"])
await _replay_v3_consumer(team_id=team.pk, schema_id=inputs.external_data_schema_id)
+ assert await _queryable_folder() == "balance_transaction__query_c"
- # Check the query folders now - all 3 sync folders should exist
- s3_objects_datetime_1 = await minio_client.list_objects_v2(
- Bucket=BUCKET_NAME, Prefix=f"{folder_path}/balance_transaction__query_{int(datetime_1.timestamp())}_"
- )
-
- s3_objects_datetime_2 = await minio_client.list_objects_v2(
- Bucket=BUCKET_NAME, Prefix=f"{folder_path}/balance_transaction__query_{int(datetime_2.timestamp())}_"
- )
-
- s3_objects_datetime_3 = await minio_client.list_objects_v2(
- Bucket=BUCKET_NAME, Prefix=f"{folder_path}/balance_transaction__query_{int(datetime_3.timestamp())}_"
- )
-
- assert len(s3_objects_datetime_1["Contents"]) != 0
- assert len(s3_objects_datetime_2["Contents"]) != 0
- assert len(s3_objects_datetime_3["Contents"]) != 0
-
- # Sync a fourth time 5 minutes later (now over 10 mins since the first sync)
- datetime_4 = datetime_3 + timedelta(minutes=5)
- with time_machine.travel(datetime_4, tick=False):
- await _execute_run(workflow_id, inputs, stripe_balance_transaction["data"])
- await _replay_v3_consumer(team_id=team.pk, schema_id=inputs.external_data_schema_id)
-
- # Check the query folders now - this should delete the first sync folder but keep three others
- s3_objects_datetime_1 = await minio_client.list_objects_v2(
- Bucket=BUCKET_NAME, Prefix=f"{folder_path}/balance_transaction__query_{int(datetime_1.timestamp())}_"
- )
-
- s3_objects_datetime_2 = await minio_client.list_objects_v2(
- Bucket=BUCKET_NAME, Prefix=f"{folder_path}/balance_transaction__query_{int(datetime_2.timestamp())}_"
- )
-
- s3_objects_datetime_3 = await minio_client.list_objects_v2(
- Bucket=BUCKET_NAME, Prefix=f"{folder_path}/balance_transaction__query_{int(datetime_3.timestamp())}_"
- )
-
- s3_objects_datetime_4 = await minio_client.list_objects_v2(
- Bucket=BUCKET_NAME, Prefix=f"{folder_path}/balance_transaction__query_{int(datetime_4.timestamp())}_"
- )
-
- assert len(s3_objects_datetime_1.get("Contents", [])) == 0 # first folder should be deleted
- assert len(s3_objects_datetime_2["Contents"]) != 0
- assert len(s3_objects_datetime_3["Contents"]) != 0
- assert len(s3_objects_datetime_4["Contents"]) != 0
-
- # Sync a fifth time 1 min later but with a reduced query file delete buffer
- datetime_5 = datetime_4 + timedelta(minutes=1)
+ # With a shorter delete buffer, slot a (not read since datetime_2) is safe to rewrite and is reused.
+ datetime_4 = datetime_3 + timedelta(minutes=1)
with (
- time_machine.travel(datetime_5, tick=False),
+ time_machine.travel(datetime_4, tick=False),
mock.patch("products.warehouse_sources.backend.temporal.data_imports.util.S3_DELETE_TIME_BUFFER", 1),
):
await _execute_run(workflow_id, inputs, stripe_balance_transaction["data"])
await _replay_v3_consumer(team_id=team.pk, schema_id=inputs.external_data_schema_id)
+ assert await _queryable_folder() == "balance_transaction__query_a"
- # Check the query folders now - this should delete all folders except the latest two
- s3_objects_datetime_1 = await minio_client.list_objects_v2(
- Bucket=BUCKET_NAME, Prefix=f"{folder_path}/balance_transaction__query_{int(datetime_1.timestamp())}_"
- )
-
- s3_objects_datetime_2 = await minio_client.list_objects_v2(
- Bucket=BUCKET_NAME, Prefix=f"{folder_path}/balance_transaction__query_{int(datetime_2.timestamp())}_"
- )
-
- s3_objects_datetime_3 = await minio_client.list_objects_v2(
- Bucket=BUCKET_NAME, Prefix=f"{folder_path}/balance_transaction__query_{int(datetime_3.timestamp())}_"
- )
-
- s3_objects_datetime_4 = await minio_client.list_objects_v2(
- Bucket=BUCKET_NAME, Prefix=f"{folder_path}/balance_transaction__query_{int(datetime_4.timestamp())}_"
- )
-
- s3_objects_datetime_5 = await minio_client.list_objects_v2(
- Bucket=BUCKET_NAME, Prefix=f"{folder_path}/balance_transaction__query_{int(datetime_5.timestamp())}_"
- )
-
- assert len(s3_objects_datetime_1.get("Contents", [])) == 0
- assert len(s3_objects_datetime_2.get("Contents", [])) == 0
- assert len(s3_objects_datetime_3.get("Contents", [])) == 0
- assert (
- len(s3_objects_datetime_4["Contents"]) != 0 # we keep the most recent two folders if they're older than 10 mins
- )
- assert len(s3_objects_datetime_5["Contents"]) != 0 # this is the latest live queryable folder
-
- # Make sure the old format query folder doesn't exist
- s3_objects_old_format = await minio_client.list_objects_v2(
- Bucket=BUCKET_NAME, Prefix=f"{folder_path}/balance_transaction__query/"
+ # No sync fell back to a fresh timestamped folder.
+ s3_objects = await minio_client.list_objects_v2(
+ Bucket=BUCKET_NAME, Prefix=f"{folder_path}/balance_transaction__query_"
)
- assert len(s3_objects_old_format.get("Contents", [])) == 0
+ folders = {obj["Key"].removeprefix(f"{folder_path}/").split("/")[0] for obj in s3_objects["Contents"]}
+ assert folders == {"balance_transaction__query_a", "balance_transaction__query_b", "balance_transaction__query_c"}
@pytest.mark.django_db(transaction=True)
diff --git a/products/warehouse_sources/backend/temporal/data_imports/tests/test_util.py b/products/warehouse_sources/backend/temporal/data_imports/tests/test_util.py
index f2c3f31580a7..28ac854b77e8 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/tests/test_util.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/tests/test_util.py
@@ -409,7 +409,6 @@ async def _prepare_double_buffered(
existing: str | None,
history: QueryFolderPointerHistory | None,
file_uris: list[str],
- double_buffer: bool = True,
) -> str:
with (
patch.object(util_module, "aget_s3_client", return_value=_FakeS3CM(s3)),
@@ -420,7 +419,7 @@ async def _prepare_double_buffered(
table_name="my_table",
file_uris=file_uris,
existing_queryable_folder=existing,
- double_buffer=double_buffer,
+ double_buffer=True,
pointer_history=history,
)
@@ -576,25 +575,19 @@ class TestDoubleBufferedQueryFolders:
assert self._copied(s3) == {f"{_JOB_URI}/{folder}/p1", f"{_JOB_URI}/{folder}/p2"}
s3._rm.assert_not_awaited()
- @parameterized.expand([("flag_on", True), ("flag_off", False)])
- async def test_age_based_cleanup_never_removes_the_slot_folders(self, _name: str, double_buffer: bool):
- # Turning the flag off after a table moved onto the slots returns it to timestamped folders;
- # the cleanup must still take the stale timestamped folders and must leave every slot alone,
- # because one of them is what readers are on right now.
+ async def test_age_based_cleanup_never_removes_the_slot_folders(self):
+ # The cleanup must still take the stale timestamped folders a table left behind before it
+ # moved onto the slots, and must leave every slot alone, because one of them is what readers
+ # are on right now.
stale = f"my_table__query_{_stale_epoch()}_0badf00d"
s3 = _fake_s3(
_ls=AsyncMock(return_value=_job_folder_listing(_SLOT_A, _SLOT_B, _SLOT_C, stale)),
_find=_find_returning({}),
)
- folder = await _prepare_double_buffered(
- s3, existing=_SLOT_A, history=_history(_SLOT_A), file_uris=_live("p1"), double_buffer=double_buffer
- )
+ folder = await _prepare_double_buffered(s3, existing=_SLOT_A, history=_history(_SLOT_A), file_uris=_live("p1"))
- if double_buffer:
- assert folder == _SLOT_B
- else:
- assert _TIMESTAMPED_FOLDER.match(folder)
+ assert folder == _SLOT_B
s3._rm.assert_awaited_once_with(f"{_JOB_KEY}/{stale}", recursive=True)
async def test_a_failed_stale_file_delete_raises_instead_of_returning_the_standby(self):
diff --git a/products/warehouse_sources/backend/temporal/data_imports/util.py b/products/warehouse_sources/backend/temporal/data_imports/util.py
index ea4b6deaf100..0feeb5c4c4a0 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/util.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/util.py
@@ -242,10 +242,6 @@ def with_internal_db_retries(fn: Callable[P, T]) -> Callable[P, T]:
# 10 mins buffer to avoid deleting files Clickhouse may be reading
S3_DELETE_TIME_BUFFER = 600
-# Per-schema rollout flag for the fixed a/b query folder pair below. Off (or unevaluable) means the
-# timestamped-folder path, so a bad rollout is undone by turning the flag off.
-DOUBLE_BUFFERED_QUERY_FOLDERS_FLAG = "data-warehouse-double-buffered-query-folders"
-
# A zombie compaction+vacuum pass (a heartbeat-timed-out activity attempt still running) can keep
# deleting source files for as long as its own rewrite takes - documented up to ~45s for a
# fragmented table in core/delta/maintenance.py, before vacuum even starts - which can outlive a
diff --git a/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/repartition_table.py b/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/repartition_table.py
index b1cc03228d0a..ab4b07e3e806 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/repartition_table.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/repartition_table.py
@@ -54,11 +54,8 @@ from products.warehouse_sources.backend.temporal.data_imports.pipelines.core.rep
)
from products.warehouse_sources.backend.temporal.data_imports.pipelines.core.repartition_controller import (
MAX_REPARTITION_ATTEMPTS,
- WAREHOUSE_AUTO_REPARTITION_FLAG,
base_event_props,
capture_repartition_event,
- is_auto_coarsen_enabled,
- is_auto_repartition_enabled,
maybe_flag_for_repartition,
needs_pre_extraction_detection,
target_partition_bytes,
@@ -125,8 +122,8 @@ def _rewrite_deadline(activity_started: float) -> float | None:
`activity_started` is the `time.monotonic()` reading taken when the activity began. The deadline
is anchored to it, not to now: the budget is measured from `start_to_close_timeout`, which Temporal
- counts from the same start, so the pre-rewrite work (job fetch, flag evaluation, the pre-extraction
- Delta-log measurement, temp validation) has to be charged against it too. Anchoring to now instead
+ counts from the same start, so the pre-rewrite work (job fetch, the pre-extraction Delta-log
+ measurement, temp validation) has to be charged against it too. Anchoring to now instead
hands the rewrite a deadline later than the activity's own timeout by however long that pre-work
took, so on the heavily-fragmented tables this path exists to rescue — where reading the log alone
runs into minutes — Temporal kills the rewrite mid-stream before it can record an outcome, and the
@@ -209,26 +206,22 @@ def _maybe_flag_pre_extraction(
job: ExternalDataJob,
table_ref: DeltaTableRef,
logger: FilteringBoundLogger,
- enabled: bool,
) -> dict[str, Any] | None:
"""Measure the on-disk table before extraction and flag a repartition if it's over budget.
The post-load detector (`maybe_flag_for_repartition`) only runs after a merge completes, so a table
whose merge OOMs every run can never flag itself for repair — the classic chicken-and-egg. Running
- the same detection (same feature-flag, budget, and cooldown gating) here, pre-extraction, closes
+ the same detection (same budget and cooldown gating) here, pre-extraction, closes
that gap: the on-disk table already reflects the over-budget layout, so we can flag and — in this
same run — rewrite it before the merge that would OOM. Returns the pending target set by detection,
or None if nothing was flagged (or the table couldn't be measured). Never raises.
-
- `enabled` is the already-evaluated rollout-flag verdict, threaded through so detection reuses it
- instead of paying for a second flag evaluation.
"""
try:
delta_table = async_to_sync(table_ref.get_delta_table)()
if delta_table is None:
logger.debug("repartition: no delta table on disk, cannot measure for repartition")
return None
- async_to_sync(maybe_flag_for_repartition)(schema, schema.source, job, delta_table, logger, enabled=enabled)
+ async_to_sync(maybe_flag_for_repartition)(schema, schema.source, job, delta_table, logger)
except Exception as e:
# Detection is best-effort; a failure here must not block the sync. `get_delta_table` re-raises
# transient object-store blips (S3/credential-provider timeouts) rather than swallowing them —
@@ -269,7 +262,7 @@ def maybe_repartition_table_activity(inputs: RepartitionActivityInputs) -> None:
def _maybe_repartition_table(inputs: RepartitionActivityInputs, logger: FilteringBoundLogger) -> None:
# Anchor the rewrite deadline to when the activity began, so the pre-rewrite work below (job fetch,
- # flag evaluation, pre-extraction Delta-log measurement) is charged against the activity's timeout
+ # pre-extraction Delta-log measurement) is charged against the activity's timeout
# rather than handed to the rewrite on top of it. See `_rewrite_deadline`.
activity_started = time.monotonic()
try:
@@ -304,19 +297,13 @@ def _maybe_repartition_table(inputs: RepartitionActivityInputs, logger: Filterin
)
return
- # Log the rollout-flag verdict (and the recorded/budget sizes) so it's clear from the Syncs UI why a
- # table does or doesn't repartition — a disabled flag is the most common reason for a no-op. Note
+ # Log the recorded and budget sizes so the Syncs UI shows what the controller started from. Note
# `max_partition_bytes` here is the last *recorded* value (can be stale); the gate does not trust
- # it, the live size is read below. Evaluate the flag once and thread the result into the
- # pre-extraction detection path so it isn't re-evaluated inside maybe_flag_for_repartition.
- enabled = is_auto_repartition_enabled(schema)
+ # it, the live size is read below.
recorded_max_partition_bytes = schema.max_partition_bytes
budget = target_partition_bytes()
logger.info(
- f"repartition: feature flag evaluated flag={WAREHOUSE_AUTO_REPARTITION_FLAG} enabled={enabled} "
- f"max_partition_bytes={recorded_max_partition_bytes} target_partition_bytes={budget}",
- flag=WAREHOUSE_AUTO_REPARTITION_FLAG,
- enabled=enabled,
+ f"repartition: evaluating max_partition_bytes={recorded_max_partition_bytes} target_partition_bytes={budget}",
max_partition_bytes=recorded_max_partition_bytes,
target_partition_bytes=budget,
)
@@ -324,34 +311,10 @@ def _maybe_repartition_table(inputs: RepartitionActivityInputs, logger: Filterin
pending = schema.repartition_pending
swap = schema.repartition_swap
- # The flag has to stop a queued rewrite too, not only detection. Once a table is flagged, the
- # rewrite runs ahead of extraction on every sync, so a rewrite that can't finish delays the sync
- # by the full activity budget indefinitely; the flag is the only lever support has to release
- # such a table, and it does nothing here if it only gates detection. Each auto-staged trigger
- # family answers to the flag that staged it, and any other reason fails open: operator-staged
- # work (admin, coarsening nominations) was queued knowing that syncing on the old layout is the
- # worse option, so it must never dead-end on a rollout flag. A staged swap is always driven to
- # completion because temp is the source of truth in that window and live may already be deleted.
- if pending is not None and swap is None:
- reason = pending.get("trigger_reason")
- if reason in ("proactive_threshold", "oom_history"):
- release = not enabled
- elif reason == "coarsening":
- release = not is_auto_coarsen_enabled(schema)
- else:
- release = False
- if release:
- logger.info(
- f"repartition: queued rewrite skipped, controller disabled by feature flag schema_id={schema.id}",
- schema_id=str(schema.id),
- trigger_reason=reason,
- )
- return
-
- # Fast no-op path: nothing queued and the gate says no on-disk measurement is needed (flag off, or
- # CDC). Return here — before fetching the job and reading the delta log — so the common healthy
- # invocation avoids all on-disk I/O. Flagged tables fall through and measure the live size below.
- if pending is None and swap is None and not needs_pre_extraction_detection(schema, enabled):
+ # Fast no-op path: nothing queued and the gate says no on-disk measurement is needed (CDC).
+ # Return here — before fetching the job and reading the delta log — so the common healthy
+ # invocation avoids all on-disk I/O. Other tables fall through and measure the live size below.
+ if pending is None and swap is None and not needs_pre_extraction_detection(schema):
logger.info("repartition: nothing queued and no detection needed, nothing to do")
return
@@ -394,10 +357,10 @@ def _maybe_repartition_table(inputs: RepartitionActivityInputs, logger: Filterin
table_ref = DeltaTableRef(resource_name=resource_name, job=job, logger=logger)
if pending is None and swap is None:
- # Nothing was queued by a prior run's post-load detection, but the gate flagged the table for an
- # on-disk measurement. Measure now and self-flag if it's over budget — the only path that can
- # rescue a table which OOMs its merge every run (and so never reaches post-load detection).
- pending = _maybe_flag_pre_extraction(schema, job, table_ref, logger, enabled)
+ # Nothing was queued by a prior run's post-load detection. Measure now and self-flag if it's
+ # over budget — the only path that can rescue a table which OOMs its merge every run (and so
+ # never reaches post-load detection).
+ pending = _maybe_flag_pre_extraction(schema, job, table_ref, logger)
if pending is None:
logger.debug("repartition: pre-extraction measurement found no repartition needed")
return
diff --git a/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/tests/test_repartition_table.py b/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/tests/test_repartition_table.py
index 5fd1700d63b0..1a487e141852 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/tests/test_repartition_table.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/tests/test_repartition_table.py
@@ -34,7 +34,6 @@ from products.warehouse_sources.backend.temporal.data_imports.workflow_activitie
)
MODULE = "products.warehouse_sources.backend.temporal.data_imports.workflow_activities.repartition_table"
-CONTROLLER_MODULE = "products.warehouse_sources.backend.temporal.data_imports.pipelines.core.repartition_controller"
TEAM_ID = 1
SCHEMA_ID = str(uuid.uuid4())
@@ -108,14 +107,12 @@ class TestRepartitionActivityDeltaFolder:
@patch(f"{MODULE}.HeartbeaterSync")
@patch(f"{MODULE}.repartition_table_in_place", new_callable=AsyncMock)
@patch(f"{MODULE}.DeltaTableRef")
- @patch(f"{MODULE}.is_auto_repartition_enabled", return_value=True)
@patch(f"{MODULE}.ExternalDataJob")
@patch(f"{MODULE}.ExternalDataSchema")
def test_repartitions_the_folder_the_pipeline_wrote_to(
self,
mock_schema_model: MagicMock,
mock_job_model: MagicMock,
- _mock_enabled: MagicMock,
mock_helper_cls: MagicMock,
mock_repartition: AsyncMock,
_mock_heartbeater: MagicMock,
@@ -151,14 +148,12 @@ class TestJobContextBinding:
@patch(f"{MODULE}.HeartbeaterSync")
@patch(f"{MODULE}.repartition_table_in_place", new_callable=AsyncMock)
@patch(f"{MODULE}.DeltaTableRef")
- @patch(f"{MODULE}.is_auto_repartition_enabled", return_value=True)
@patch(f"{MODULE}.ExternalDataJob")
@patch(f"{MODULE}.ExternalDataSchema")
def test_activity_binds_source_and_schema_identity_for_captured_exceptions(
self,
mock_schema_model: MagicMock,
mock_job_model: MagicMock,
- _mock_enabled: MagicMock,
_mock_helper_cls: MagicMock,
mock_repartition: AsyncMock,
_mock_heartbeater: MagicMock,
@@ -241,7 +236,6 @@ class TestBudgetExhaustion:
@patch(f"{MODULE}.HeartbeaterSync")
@patch(f"{MODULE}.repartition_table_in_place", new_callable=AsyncMock)
@patch(f"{MODULE}.DeltaTableRef")
- @patch(f"{MODULE}.is_auto_repartition_enabled", return_value=True)
@patch(f"{MODULE}.ExternalDataJob")
@patch(f"{MODULE}.ExternalDataSchema")
def test_stalled_rewrite_burns_an_attempt_and_gives_up_with_a_cooldown(
@@ -251,7 +245,6 @@ class TestBudgetExhaustion:
expect_give_up: bool,
mock_schema_model: MagicMock,
_mock_job_model: MagicMock,
- _mock_enabled: MagicMock,
_mock_helper_cls: MagicMock,
mock_repartition: AsyncMock,
_mock_heartbeater: MagicMock,
@@ -294,7 +287,6 @@ class TestBudgetExhaustion:
@patch(f"{MODULE}.HeartbeaterSync")
@patch(f"{MODULE}.repartition_table_in_place", new_callable=AsyncMock)
@patch(f"{MODULE}.DeltaTableRef")
- @patch(f"{MODULE}.is_auto_repartition_enabled", return_value=True)
@patch(f"{MODULE}.ExternalDataJob")
@patch(f"{MODULE}.ExternalDataSchema")
def test_progressing_rewrite_resumes_without_burning_an_attempt(
@@ -303,7 +295,6 @@ class TestBudgetExhaustion:
prior_attempts: int,
mock_schema_model: MagicMock,
_mock_job_model: MagicMock,
- _mock_enabled: MagicMock,
_mock_helper_cls: MagicMock,
mock_repartition: AsyncMock,
_mock_heartbeater: MagicMock,
@@ -345,14 +336,12 @@ class TestBudgetExhaustion:
@patch(f"{MODULE}.HeartbeaterSync")
@patch(f"{MODULE}.repartition_table_in_place", new_callable=AsyncMock)
@patch(f"{MODULE}.DeltaTableRef")
- @patch(f"{MODULE}.is_auto_repartition_enabled", return_value=True)
@patch(f"{MODULE}.ExternalDataJob")
@patch(f"{MODULE}.ExternalDataSchema")
def test_first_over_budget_attempt_that_checkpoints_is_progress_not_a_failure(
self,
mock_schema_model: MagicMock,
_mock_job_model: MagicMock,
- _mock_enabled: MagicMock,
_mock_helper_cls: MagicMock,
mock_repartition: AsyncMock,
_mock_heartbeater: MagicMock,
@@ -387,7 +376,6 @@ class TestBudgetExhaustion:
@patch(f"{MODULE}.HeartbeaterSync")
@patch(f"{MODULE}.repartition_table_in_place", new_callable=AsyncMock)
@patch(f"{MODULE}.DeltaTableRef")
- @patch(f"{MODULE}.is_auto_repartition_enabled", return_value=True)
@patch(f"{MODULE}.ExternalDataJob")
@patch(f"{MODULE}.ExternalDataSchema")
def test_restarted_rewrite_burns_an_attempt_however_many_rows_it_wrote(
@@ -397,7 +385,6 @@ class TestBudgetExhaustion:
expect_give_up: bool,
mock_schema_model: MagicMock,
_mock_job_model: MagicMock,
- _mock_enabled: MagicMock,
_mock_helper_cls: MagicMock,
mock_repartition: AsyncMock,
_mock_heartbeater: MagicMock,
@@ -436,14 +423,12 @@ class TestBudgetExhaustion:
@patch(f"{MODULE}.HeartbeaterSync")
@patch(f"{MODULE}.repartition_table_in_place", new_callable=AsyncMock)
@patch(f"{MODULE}.DeltaTableRef")
- @patch(f"{MODULE}.is_auto_repartition_enabled", return_value=True)
@patch(f"{MODULE}.ExternalDataJob")
@patch(f"{MODULE}.ExternalDataSchema")
def test_a_staged_swap_is_resumed_even_after_attempts_are_spent(
self,
mock_schema_model: MagicMock,
_mock_job_model: MagicMock,
- _mock_enabled: MagicMock,
_mock_helper_cls: MagicMock,
mock_repartition: AsyncMock,
_mock_heartbeater: MagicMock,
@@ -481,7 +466,6 @@ class TestBudgetExhaustion:
@patch(f"{MODULE}.HeartbeaterSync")
@patch(f"{MODULE}.repartition_table_in_place", new_callable=AsyncMock)
@patch(f"{MODULE}.DeltaTableRef")
- @patch(f"{MODULE}.is_auto_repartition_enabled", return_value=True)
@patch(f"{MODULE}.ExternalDataJob")
@patch(f"{MODULE}.ExternalDataSchema")
def test_a_skipped_rewrite_does_not_consume_an_attempt(
@@ -489,7 +473,6 @@ class TestBudgetExhaustion:
reason: str,
mock_schema_model: MagicMock,
_mock_job_model: MagicMock,
- _mock_enabled: MagicMock,
_mock_helper_cls: MagicMock,
mock_repartition: AsyncMock,
_mock_heartbeater: MagicMock,
@@ -534,7 +517,6 @@ class TestKilledAttemptRetry:
@patch(f"{MODULE}.HeartbeaterSync")
@patch(f"{MODULE}.repartition_table_in_place", new_callable=AsyncMock)
@patch(f"{MODULE}.DeltaTableRef")
- @patch(f"{MODULE}.is_auto_repartition_enabled", return_value=True)
@patch(f"{MODULE}.ExternalDataJob")
@patch(f"{MODULE}.ExternalDataSchema")
def test_a_retry_reruns_the_rewrite_only_when_the_dead_attempt_advanced_it(
@@ -547,7 +529,6 @@ class TestKilledAttemptRetry:
expect_rewrite: bool,
mock_schema_model: MagicMock,
_mock_job_model: MagicMock,
- _mock_enabled: MagicMock,
_mock_helper_cls: MagicMock,
mock_repartition: AsyncMock,
_mock_heartbeater: MagicMock,
@@ -617,8 +598,6 @@ class TestKilledAttemptRetry:
@patch(f"{MODULE}.HeartbeaterSync")
@patch(f"{MODULE}.repartition_table_in_place", new_callable=AsyncMock)
@patch(f"{MODULE}.DeltaTableRef")
- @patch(f"{MODULE}.is_auto_coarsen_enabled", return_value=True)
- @patch(f"{MODULE}.is_auto_repartition_enabled", return_value=True)
@patch(f"{MODULE}.ExternalDataJob")
@patch(f"{MODULE}.ExternalDataSchema")
def test_the_cap_gives_up_only_on_a_rewrite_that_stopped_advancing(
@@ -631,8 +610,6 @@ class TestKilledAttemptRetry:
expect_resume: bool,
mock_schema_model: MagicMock,
_mock_job_model: MagicMock,
- _mock_enabled: MagicMock,
- _mock_coarsen_enabled: MagicMock,
_mock_helper_cls: MagicMock,
mock_repartition: AsyncMock,
_mock_heartbeater: MagicMock,
@@ -691,16 +668,12 @@ class TestKilledAttemptRetry:
@patch(f"{MODULE}.HeartbeaterSync")
@patch(f"{MODULE}.repartition_table_in_place", new_callable=AsyncMock)
@patch(f"{MODULE}.DeltaTableRef")
- @patch(f"{MODULE}.is_auto_coarsen_enabled", return_value=True)
- @patch(f"{MODULE}.is_auto_repartition_enabled", return_value=True)
@patch(f"{MODULE}.ExternalDataJob")
@patch(f"{MODULE}.ExternalDataSchema")
def test_the_cap_does_not_discard_a_swap_staged_while_it_was_deciding(
self,
mock_schema_model: MagicMock,
_mock_job_model: MagicMock,
- _mock_enabled: MagicMock,
- _mock_coarsen_enabled: MagicMock,
_mock_helper_cls: MagicMock,
mock_repartition: AsyncMock,
_mock_heartbeater: MagicMock,
@@ -754,14 +727,12 @@ class TestTransientObjectStoreFailure:
@patch(f"{MODULE}.HeartbeaterSync")
@patch(f"{MODULE}.repartition_table_in_place", new_callable=AsyncMock)
@patch(f"{MODULE}.DeltaTableRef")
- @patch(f"{MODULE}.is_auto_repartition_enabled", return_value=True)
@patch(f"{MODULE}.ExternalDataJob")
@patch(f"{MODULE}.ExternalDataSchema")
def test_bare_nosuchkey_stands_down_without_burning_an_attempt(
self,
mock_schema_model: MagicMock,
_mock_job_model: MagicMock,
- _mock_enabled: MagicMock,
_mock_helper_cls: MagicMock,
mock_repartition: AsyncMock,
_mock_heartbeater: MagicMock,
@@ -806,7 +777,6 @@ class TestTransientObjectStoreFailure:
@patch(f"{MODULE}.HeartbeaterSync")
@patch(f"{MODULE}.repartition_table_in_place", new_callable=AsyncMock)
@patch(f"{MODULE}.DeltaTableRef")
- @patch(f"{MODULE}.is_auto_repartition_enabled", return_value=True)
@patch(f"{MODULE}.ExternalDataJob")
@patch(f"{MODULE}.ExternalDataSchema")
def test_db_connection_drop_stands_down_without_reporting_to_error_tracking(
@@ -815,7 +785,6 @@ class TestTransientObjectStoreFailure:
error: Exception,
mock_schema_model: MagicMock,
_mock_job_model: MagicMock,
- _mock_enabled: MagicMock,
_mock_helper_cls: MagicMock,
mock_repartition: AsyncMock,
_mock_heartbeater: MagicMock,
@@ -863,7 +832,6 @@ class TestTransientObjectStoreFailure:
@patch(f"{MODULE}.HeartbeaterSync")
@patch(f"{MODULE}.repartition_table_in_place", new_callable=AsyncMock)
@patch(f"{MODULE}.DeltaTableRef")
- @patch(f"{MODULE}.is_auto_repartition_enabled", return_value=True)
@patch(f"{MODULE}.ExternalDataJob")
@patch(f"{MODULE}.ExternalDataSchema")
def test_object_store_blip_stands_down_without_burning_an_attempt(
@@ -872,7 +840,6 @@ class TestTransientObjectStoreFailure:
error: Exception,
mock_schema_model: MagicMock,
_mock_job_model: MagicMock,
- _mock_enabled: MagicMock,
_mock_helper_cls: MagicMock,
mock_repartition: AsyncMock,
_mock_heartbeater: MagicMock,
@@ -904,14 +871,12 @@ class TestTransientObjectStoreFailure:
@patch(f"{MODULE}.HeartbeaterSync")
@patch(f"{MODULE}.repartition_table_in_place", new_callable=AsyncMock)
@patch(f"{MODULE}.DeltaTableRef")
- @patch(f"{MODULE}.is_auto_repartition_enabled", return_value=True)
@patch(f"{MODULE}.ExternalDataJob")
@patch(f"{MODULE}.ExternalDataSchema")
def test_a_database_blip_after_the_swap_is_reported_not_shrugged_off(
self,
mock_schema_model: MagicMock,
_mock_job_model: MagicMock,
- _mock_enabled: MagicMock,
_mock_helper_cls: MagicMock,
mock_repartition: AsyncMock,
_mock_heartbeater: MagicMock,
@@ -953,14 +918,12 @@ class TestTransientObjectStoreFailure:
@patch(f"{MODULE}.HeartbeaterSync")
@patch(f"{MODULE}.repartition_table_in_place", new_callable=AsyncMock)
@patch(f"{MODULE}.DeltaTableRef")
- @patch(f"{MODULE}.is_auto_repartition_enabled", return_value=True)
@patch(f"{MODULE}.ExternalDataJob")
@patch(f"{MODULE}.ExternalDataSchema")
def test_a_native_panic_is_recorded_instead_of_escaping(
self,
mock_schema_model: MagicMock,
_mock_job_model: MagicMock,
- _mock_enabled: MagicMock,
_mock_helper_cls: MagicMock,
mock_repartition: AsyncMock,
_mock_heartbeater: MagicMock,
@@ -992,14 +955,12 @@ class TestTransientObjectStoreFailure:
@patch(f"{MODULE}.HeartbeaterSync")
@patch(f"{MODULE}.repartition_table_in_place", new_callable=AsyncMock)
@patch(f"{MODULE}.DeltaTableRef")
- @patch(f"{MODULE}.is_auto_repartition_enabled", return_value=True)
@patch(f"{MODULE}.ExternalDataJob")
@patch(f"{MODULE}.ExternalDataSchema")
def test_a_worker_shutdown_still_propagates(
self,
mock_schema_model: MagicMock,
_mock_job_model: MagicMock,
- _mock_enabled: MagicMock,
_mock_helper_cls: MagicMock,
mock_repartition: AsyncMock,
_mock_heartbeater: MagicMock,
@@ -1069,14 +1030,12 @@ class TestEarlyFetchTransientInfraError:
mock_capture_exception.assert_not_called()
@patch(f"{MODULE}.capture_exception")
- @patch(f"{MODULE}.is_auto_repartition_enabled", return_value=True)
@patch(f"{MODULE}.ExternalDataJob")
@patch(f"{MODULE}.ExternalDataSchema")
def test_transient_db_error_fetching_job_stands_down(
self,
mock_schema_model: MagicMock,
mock_job_model: MagicMock,
- _mock_enabled: MagicMock,
mock_capture_exception: MagicMock,
) -> None:
schema = _schema(name="public.usages", s3_folder_name="usages")
@@ -1092,62 +1051,6 @@ class TestEarlyFetchTransientInfraError:
mock_capture_exception.assert_not_called()
-class TestFeatureFlagGate:
- @parameterized.expand(
- [
- ("flag_off_releases_a_queued_rewrite", False, True, None, "proactive_threshold", False),
- ("flag_off_still_finishes_a_staged_swap", False, True, {"state": "ready"}, "proactive_threshold", True),
- ("flag_off_does_not_block_an_operator", False, True, None, "admin", True),
- ("flag_on_rewrites_as_usual", True, True, None, "proactive_threshold", True),
- ("flag_off_does_not_release_a_nomination", False, False, None, "coarsening_requested", True),
- ("coarsen_flag_off_releases_a_queued_coarsen", True, False, None, "coarsening", False),
- ("repartition_flag_off_keeps_a_queued_coarsen", False, True, None, "coarsening", True),
- ]
- )
- @patch(f"{MODULE}.capture_repartition_event")
- @patch(f"{MODULE}.HeartbeaterSync")
- @patch(f"{MODULE}.repartition_table_in_place", new_callable=AsyncMock)
- @patch(f"{MODULE}.DeltaTableRef")
- @patch(f"{MODULE}.is_auto_coarsen_enabled")
- @patch(f"{MODULE}.is_auto_repartition_enabled")
- @patch(f"{MODULE}.ExternalDataJob")
- @patch(f"{MODULE}.ExternalDataSchema")
- def test_flag_gates_the_queued_rewrite(
- self,
- _name: str,
- enabled: bool,
- coarsen_enabled: bool,
- swap: dict | None,
- trigger_reason: str,
- expect_rewrite: bool,
- mock_schema_model: MagicMock,
- _mock_job_model: MagicMock,
- mock_enabled: MagicMock,
- mock_coarsen_enabled: MagicMock,
- _mock_helper_cls: MagicMock,
- mock_repartition: AsyncMock,
- _mock_heartbeater: MagicMock,
- _mock_capture_event: MagicMock,
- ) -> None:
- mock_enabled.return_value = enabled
- mock_coarsen_enabled.return_value = coarsen_enabled
- schema = _schema(
- name="public.usages",
- s3_folder_name="usages",
- pending={**PENDING_TARGET, "trigger_reason": trigger_reason},
- swap=swap,
- )
- mock_schema_model.objects.select_related.return_value.get.return_value = schema
- mock_repartition.return_value = {"outcome": "completed"}
-
- _maybe_repartition_table(
- RepartitionActivityInputs(team_id=TEAM_ID, schema_id=SCHEMA_ID, job_id=JOB_ID, source_id=SOURCE_ID),
- MagicMock(),
- )
-
- assert mock_repartition.await_count == (1 if expect_rewrite else 0)
-
-
class TestRepartitionActivityHasWork:
@parameterized.expand(
[
@@ -1156,49 +1059,26 @@ class TestRepartitionActivityHasWork:
{"delta_revive_required": {"at": "x"}},
PENDING_TARGET,
None,
- None,
- True,
- False,
- ),
- ("queued_rewrite_flag_on", {}, PENDING_TARGET, None, None, True, True),
- # The activity's own fast path treats a queued rewrite as a no-op once the flag that
- # staged it is disabled (the flag is the only lever support has to release such a table) —
- # this must agree, or the schema keeps paying a full activity round trip forever.
- ("queued_rewrite_released_by_disabled_flag", {}, PENDING_TARGET, None, None, False, False),
- (
- "queued_rewrite_admin_reason_fails_open",
- {},
- {**PENDING_TARGET, "trigger_reason": "admin"},
- None,
- None,
False,
- True,
),
- ("staged_swap", {}, None, {"state": "ready"}, None, False, True),
- ("flag_on_measures_the_table", {}, None, None, None, True, True),
- ("flag_off_nothing_queued", {}, None, None, None, False, False),
- ("coarsen_nomination_without_flag", {}, None, None, {"requested_by": "op"}, False, True),
- ("cdc_never_measures", {"sync_type": ExternalDataSchema.SyncType.CDC}, None, None, None, True, False),
+ ("queued_rewrite", {}, PENDING_TARGET, None, True),
+ ("staged_swap", {}, None, {"state": "ready"}, True),
+ ("nothing_queued_measures_the_table", {}, None, None, True),
+ ("cdc_never_measures", {"sync_type": ExternalDataSchema.SyncType.CDC}, None, None, False),
]
)
- @patch(f"{CONTROLLER_MODULE}.is_auto_repartition_enabled")
def test_matches_the_activitys_own_fast_path(
self,
_name: str,
overrides: dict[str, Any],
pending: dict[str, Any] | None,
swap: dict[str, Any] | None,
- coarsen_requested: dict[str, Any] | None,
- enabled: bool,
expected: bool,
- mock_enabled: MagicMock,
) -> None:
# The workflow skips scheduling the activity on this answer, so a False here for a table the
# activity would have rewritten or measured silently stops that table repartitioning.
- mock_enabled.return_value = enabled
schema = _schema(name="public.usages", s3_folder_name="usages", pending=pending, swap=swap)
schema.sync_type = ExternalDataSchema.SyncType.INCREMENTAL
- schema.coarsen_requested = coarsen_requested
for attribute, value in overrides.items():
setattr(schema, attribute, value)
@@ -1232,7 +1112,7 @@ class TestMaybeFlagPreExtraction:
helper = MagicMock()
helper.get_delta_table = AsyncMock(side_effect=TransientObjectStoreError(message))
- result = _maybe_flag_pre_extraction(schema, MagicMock(), helper, MagicMock(), enabled=True)
+ result = _maybe_flag_pre_extraction(schema, MagicMock(), helper, MagicMock())
assert result is None
mock_capture.assert_not_called()
@@ -1254,7 +1134,7 @@ class TestMaybeFlagPreExtraction:
helper = MagicMock()
helper.get_delta_table = AsyncMock(side_effect=error)
- result = _maybe_flag_pre_extraction(schema, MagicMock(), helper, MagicMock(), enabled=True)
+ result = _maybe_flag_pre_extraction(schema, MagicMock(), helper, MagicMock())
assert result is None
mock_capture.assert_not_called()
@@ -1266,7 +1146,7 @@ class TestMaybeFlagPreExtraction:
error = ValueError("unexpected schema drift")
helper.get_delta_table = AsyncMock(side_effect=error)
- result = _maybe_flag_pre_extraction(schema, MagicMock(), helper, MagicMock(), enabled=True)
+ result = _maybe_flag_pre_extraction(schema, MagicMock(), helper, MagicMock())
assert result is None
mock_capture.assert_called_once_with(error)