:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
chore(modeling): relax retries and timeouts for v2 workflows (#59991)
andrew j. mcgehee1d3f3eb0d349
diff --git a/posthog/temporal/data_modeling/workflows/execute_dag.py b/posthog/temporal/data_modeling/workflows/execute_dag.pyindex 4df3253dde1f..7c0f09b1e179 100644--- a/posthog/temporal/data_modeling/workflows/execute_dag.py+++ b/posthog/temporal/data_modeling/workflows/execute_dag.py@@ -204,7 +204,7 @@ class ExecuteDAGWorkflow(PostHogWorkflow):),start_to_close_timeout=dt.timedelta(minutes=5),retry_policy=temporalio.common.RetryPolicy(- maximum_attempts=2,+ maximum_attempts=3,),)try:@@ -227,7 +227,7 @@ class ExecuteDAGWorkflow(PostHogWorkflow):),start_to_close_timeout=dt.timedelta(minutes=5),retry_policy=temporalio.common.RetryPolicy(- maximum_attempts=2,+ maximum_attempts=3,),)executable_nodes = dag_structure.executable_nodesdiff --git a/posthog/temporal/data_modeling/workflows/materialize_view.py b/posthog/temporal/data_modeling/workflows/materialize_view.pyindex 97a1452f01cb..cae097661723 100644--- a/posthog/temporal/data_modeling/workflows/materialize_view.py+++ b/posthog/temporal/data_modeling/workflows/materialize_view.py@@ -2,13 +2,9 @@ import jsonimport datetime as dtimport dataclasses-from django.conf import settings-import temporalio.commonimport temporalio.workflowimport temporalio.exceptions-from temporalio.exceptions import WorkflowAlreadyStartedError-from temporalio.workflow import ParentClosePolicyfrom posthog.exceptions_capture import capture_exceptionfrom posthog.temporal.common.base import PostHogWorkflow@@ -42,7 +38,6 @@ from posthog.temporal.data_modeling.metrics import (get_node_storage_delta_mib_metric,get_node_total_storage_mib_metric,)-from posthog.temporal.ducklake.types import DataModelingDuckLakeCopyInputs, DuckLakeCopyModelInputfrom products.data_modeling.backend.models.data_modeling_job import DataModelingJobEngine@@ -132,9 +127,9 @@ class MaterializeViewWorkflow(PostHogWorkflow):duckgres_enabled = await temporalio.workflow.execute_activity(check_duckgres_shadow_enabled_activity,inputs.team_id,- start_to_close_timeout=dt.timedelta(minutes=1),+ start_to_close_timeout=dt.timedelta(minutes=5),retry_policy=temporalio.common.RetryPolicy(- maximum_attempts=1,+ maximum_attempts=3,),)@@ -149,9 +144,9 @@ class MaterializeViewWorkflow(PostHogWorkflow):engine=DataModelingJobEngine.DUCKGRES,parent_workflow_id=parent_workflow_id,),- start_to_close_timeout=dt.timedelta(minutes=1),+ start_to_close_timeout=dt.timedelta(minutes=5),retry_policy=temporalio.common.RetryPolicy(- maximum_attempts=1,+ maximum_attempts=3,),)# fire-and-forget: start duckgres shadow materialization in parallel@@ -164,7 +159,7 @@ class MaterializeViewWorkflow(PostHogWorkflow):job_id=duckgres_job_id,dangerously_execute_raw_sql=inputs.dangerously_execute_raw_sql,),- start_to_close_timeout=dt.timedelta(minutes=15),+ start_to_close_timeout=dt.timedelta(minutes=20),retry_policy=temporalio.common.RetryPolicy(maximum_attempts=3 if inputs.duckgres_only else 1,initial_interval=dt.timedelta(seconds=10),@@ -181,9 +176,9 @@ class MaterializeViewWorkflow(PostHogWorkflow):dag_id=inputs.dag_id,parent_workflow_id=parent_workflow_id,),- start_to_close_timeout=dt.timedelta(minutes=1),+ start_to_close_timeout=dt.timedelta(minutes=5),retry_policy=temporalio.common.RetryPolicy(- maximum_attempts=1,+ maximum_attempts=3,),)try:@@ -196,7 +191,7 @@ class MaterializeViewWorkflow(PostHogWorkflow):job_id=job_id,),# clickhouse timeout is 10mins so start to close is that plus a bit of margin- start_to_close_timeout=dt.timedelta(minutes=15),+ start_to_close_timeout=dt.timedelta(minutes=20),heartbeat_timeout=dt.timedelta(minutes=2),retry_policy=temporalio.common.RetryPolicy(maximum_attempts=3,@@ -223,37 +218,6 @@ class MaterializeViewWorkflow(PostHogWorkflow):maximum_attempts=3,),)- try:- model = DuckLakeCopyModelInput(- model_label=materialize_result.node_name,- saved_query_id=materialize_result.saved_query_id,- table_uri=materialize_result.table_uri,- )- ducklake_inputs = DataModelingDuckLakeCopyInputs(- team_id=inputs.team_id, job_id=job_id, models=[model]- )- await temporalio.workflow.start_child_workflow(- workflow="ducklake-copy.data-modeling",- arg=dataclasses.asdict(ducklake_inputs),- id=f"ducklake-copy-data-modeling-{inputs.team_id}-{materialize_result.saved_query_id}",- task_queue=settings.DUCKLAKE_TASK_QUEUE,- parent_close_policy=ParentClosePolicy.ABANDON,- retry_policy=temporalio.common.RetryPolicy(- maximum_attempts=1,- non_retryable_error_types=["NondeterminismError"],- ),- )- except WorkflowAlreadyStartedError:- temporalio.workflow.logger.warning(- "DuckLake copy already running, skipping",- saved_query_id=materialize_result.saved_query_id,- )- except Exception as ducklake_err:- temporalio.workflow.logger.warning(- f"DuckLake copy workflow failed: {str(ducklake_err)}",- extra=inputs.properties_to_log,- )- capture_exception(ducklake_err)# handle successend_time = temporalio.workflow.now()duration_seconds = (end_time - start_time).total_seconds()