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.

fix(managed-warehouse): allow six-hour trino shadow execution (#111981)

Eric Duongfade60d21a42
diff --git a/posthog/temporal/data_modeling/workflows/materialize_view.py b/posthog/temporal/data_modeling/workflows/materialize_view.py
index 8f88418002b5..e903fd316098 100644
--- a/posthog/temporal/data_modeling/workflows/materialize_view.py
+++ b/posthog/temporal/data_modeling/workflows/materialize_view.py
@@ -260,7 +260,7 @@ class MaterializeViewWorkflow(PostHogWorkflow):
dangerously_execute_raw_sql=inputs.dangerously_execute_raw_sql,
use_trino=use_trino,
),
- start_to_close_timeout=dt.timedelta(minutes=35 if use_trino else 20),
+ start_to_close_timeout=dt.timedelta(minutes=365 if use_trino else 20),
heartbeat_timeout=dt.timedelta(minutes=2) if use_trino else None,
cancellation_type=(
temporalio.workflow.ActivityCancellationType.WAIT_CANCELLATION_COMPLETED
diff --git a/posthog/temporal/tests/data_modeling/test_materialize_view_workflow.py b/posthog/temporal/tests/data_modeling/test_materialize_view_workflow.py
index 3f4d9e869bfe..81198f6dd699 100644
--- a/posthog/temporal/tests/data_modeling/test_materialize_view_workflow.py
+++ b/posthog/temporal/tests/data_modeling/test_materialize_view_workflow.py
@@ -423,7 +423,7 @@ class TestQualityGateBranching:
collect.assert_awaited_once()
assert start_shadow.call_args.args[1].use_trino is trino_patch
assert start_shadow.call_args.kwargs["start_to_close_timeout"] == dt.timedelta(
- minutes=35 if trino_patch else 20
+ minutes=365 if trino_patch else 20
)
diff --git a/products/managed_warehouse/backend/README.md b/products/managed_warehouse/backend/README.md
index e050a829d6d0..0599dae130f4 100644
--- a/products/managed_warehouse/backend/README.md
+++ b/products/managed_warehouse/backend/README.md
@@ -73,7 +73,7 @@ The manual trigger is deliberately separate from provisioning. A future provisio
Data modeling shadow materialization starts only when its feature flag is enabled, the managed warehouse is provisioned, the organization has a ready Trino target, and the saved query has a compiled translation for its current definition. Missing, failed, stale, or empty translations keep the shadow path disabled.
-Trino shadow materialization has a 30-minute execution deadline. Its Temporal activity allows 35 minutes so cancellation and cleanup can finish before the activity times out, and requires a heartbeat every two minutes. Deadline failures retain an explicit timeout message on the modeling job. Alias reconciliation keeps its separate five-minute execution deadline.
+Trino shadow materialization has a six-hour execution deadline. Its Temporal activity allows six hours and five minutes so cancellation and cleanup can finish before the activity times out, and requires a heartbeat every two minutes. Deadline failures retain an explicit timeout message on the modeling job. Alias reconciliation keeps its separate five-minute execution deadline.
## Environment variables
diff --git a/products/managed_warehouse/backend/trino_execution.py b/products/managed_warehouse/backend/trino_execution.py
index 9cdb628b9cd9..ede6e2102906 100644
--- a/products/managed_warehouse/backend/trino_execution.py
+++ b/products/managed_warehouse/backend/trino_execution.py
@@ -15,7 +15,7 @@ if TYPE_CHECKING:
_Result = TypeVar("_Result")
-TRINO_QUERY_SECONDS = 30 * 60
+TRINO_QUERY_SECONDS = 6 * 60 * 60
_executor = ThreadPoolExecutor(thread_name_prefix="trino-model")