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(weekly-digest): allow generation to use its full time budget (#104044)

Pawel Cebula379e25ac3588
diff --git a/posthog/temporal/tests/weekly_digest/test_workflows.py b/posthog/temporal/tests/weekly_digest/test_workflows.py
index 189a3a241c4b..a85a7a057f92 100644
--- a/posthog/temporal/tests/weekly_digest/test_workflows.py
+++ b/posthog/temporal/tests/weekly_digest/test_workflows.py
@@ -71,6 +71,7 @@ _test_state: _TestState = {"generate_called": False, "send_called": False, "capt
class MockGenerateDigestDataWorkflow:
@workflow.run
async def run(self, input: GenerateDigestDataInput) -> None:
+ await workflow.sleep(timedelta(hours=7))
_test_state["generate_called"] = True
@@ -153,7 +154,7 @@ class LegacyGenerateDigestDataWorkflow:
@pytest.mark.asyncio
async def test_weekly_digest_workflow():
- """Test the main weekly digest workflow that orchestrates generation and sending."""
+ """Generation can take seven hours and still complete before sending starts."""
_test_state["generate_called"] = False
_test_state["send_called"] = False
diff --git a/posthog/temporal/weekly_digest/README.md b/posthog/temporal/weekly_digest/README.md
index 7061134dc1ea..8ee01cfd87b3 100644
--- a/posthog/temporal/weekly_digest/README.md
+++ b/posthog/temporal/weekly_digest/README.md
@@ -13,6 +13,10 @@ Team-level generation keeps at most 100 activities pending per workflow to stay
Every team range and report generator must finish before organization aggregation starts.
A Temporal patch marker preserves the activity scheduling behavior when replaying older histories.
+Generation has a 15-hour run timeout and a 15-hour execution timeout shared across its two allowed attempts.
+A healthy run can use the full generation budget without restarting and regenerating completed batches after six hours.
+Sending starts only after generation succeeds and has separate six-hour run and 15-hour execution timeouts.
+
## Redis Storage Structure
Data is stored with keys prefixed by `{digest_key}` (e.g., `weekly-digest-2024-01`).
diff --git a/posthog/temporal/weekly_digest/workflows.py b/posthog/temporal/weekly_digest/workflows.py
index a20bea4ca9d1..5b2bf4533fb4 100644
--- a/posthog/temporal/weekly_digest/workflows.py
+++ b/posthog/temporal/weekly_digest/workflows.py
@@ -86,7 +86,7 @@ class WeeklyDigestWorkflow(PostHogWorkflow):
),
parent_close_policy=workflow.ParentClosePolicy.REQUEST_CANCEL,
execution_timeout=timedelta(hours=15),
- run_timeout=timedelta(hours=6),
+ run_timeout=timedelta(hours=15),
retry_policy=common.RetryPolicy(
maximum_attempts=2,
initial_interval=timedelta(minutes=10),