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.

feat(data-warehouse): show suspended materializations and offer resume (#75412)

Jovan Sakovica042101f75b6
diff --git a/frontend/src/lib/constants.tsx b/frontend/src/lib/constants.tsx
index cfc22b32dd47..0e5e0295c65b 100644
--- a/frontend/src/lib/constants.tsx
+++ b/frontend/src/lib/constants.tsx
@@ -284,6 +284,7 @@ export const FEATURE_FLAGS = {
DASHBOARDS_LIST_VIEW: 'dashboards-list-view', // owner: @vdekrijger #team-product-analytics multivariate=control,tree
DATA_MODELING_BACKEND_V2: 'data-modeling-backend-v2', // owner: #team-data-modeling
DATA_MODELING_MULTI_DAG: 'data-modeling-multi-dag', // owner: #team-data-modeling
+ DATA_MODELING_SUSPEND_FAILING_NODES: 'data-modeling-suspend-failing-nodes', // owner: #team-data-modeling
DATA_MODELING_TAB: 'data-modeling-tab', // owner: #team-data-modeling
DATA_WAREHOUSE_COLUMN_STATISTICS: 'data-warehouse-column-statistics', // owner: #team-warehouse-sources
DATA_WAREHOUSE_CUSTOM_SOURCE_AI_BUILDER: 'dwh-custom-source-ai-builder', // owner: #team-warehouse-sources
diff --git a/frontend/src/scenes/data-warehouse/saved_queries/MaterializationStatusPanel.tsx b/frontend/src/scenes/data-warehouse/saved_queries/MaterializationStatusPanel.tsx
index 07e2dd6fecab..b02ead28e5fd 100644
--- a/frontend/src/scenes/data-warehouse/saved_queries/MaterializationStatusPanel.tsx
+++ b/frontend/src/scenes/data-warehouse/saved_queries/MaterializationStatusPanel.tsx
@@ -1,14 +1,16 @@
import { useActions, useValues } from 'kea'
import { IconRefresh, IconRevert, IconX } from '@posthog/icons'
-import { LemonDialog, LemonTable, Link, Spinner } from '@posthog/lemon-ui'
+import { LemonBanner, LemonDialog, LemonTable, Link, Spinner } from '@posthog/lemon-ui'
+import { FEATURE_FLAGS } from 'lib/constants'
import { dayjsUtcToTimezone } from 'lib/dayjs'
import { LemonButton } from 'lib/lemon-ui/LemonButton'
import { LemonProgress } from 'lib/lemon-ui/LemonProgress'
import { LemonSelect } from 'lib/lemon-ui/LemonSelect'
import { LemonTag, LemonTagType } from 'lib/lemon-ui/LemonTag'
import { Tooltip } from 'lib/lemon-ui/Tooltip'
+import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
import { getAccessControlDisabledReason } from 'lib/utils/accessControlUtils'
import { humanFriendlyDetailedTime } from 'lib/utils/datetime'
import { humanFriendlyDuration } from 'lib/utils/durations'
@@ -31,6 +33,9 @@ import { materializationJobsLogic } from './materializationJobsLogic'
const LOG_LEVELS: LogEntryLevel[] = ['LOG', 'INFO', 'WARN', 'WARNING', 'ERROR']
+// Matches DataModelingJobEngine.CLICKHOUSE, the engine materialized queries are served from.
+const SERVING_ENGINE = 'clickhouse'
+
interface MaterializationStatusPanelProps {
viewId: string
/**
@@ -137,10 +142,13 @@ export function MaterializationStatusPanel({ viewId, kind = 'view' }: Materializ
dataModelingJobsLoading,
hasMoreJobsToLoad,
startingMaterialization,
+ resumingMaterialization,
savedQuery,
savedQueryLoading,
} = useValues(jobsLogic)
- const { loadDataModelingJobs, loadOlderDataModelingJobs, setStartingMaterialization } = useActions(jobsLogic)
+ const { loadDataModelingJobs, loadOlderDataModelingJobs, setStartingMaterialization, resumeMaterialization } =
+ useActions(jobsLogic)
+ const { featureFlags } = useValues(featureFlagLogic)
const { updatingDataWarehouseSavedQuery } = useValues(dataWarehouseViewsLogic)
const {
@@ -175,6 +183,15 @@ export function MaterializationStatusPanel({ viewId, kind = 'view' }: Materializ
const currentJobStatus = dataModelingJobs?.results?.[0]?.status || null
const { sync, cancel, revert } = getMaterializationDisabledReasons(currentJobStatus, startingMaterialization)
+ // Prefer the serving engine's entry when several engines are suspended.
+ const suspension = savedQuery.suspended
+ ? (savedQuery.suspended[SERVING_ENGINE] ?? Object.values(savedQuery.suspended)[0])
+ : undefined
+ const showSuspendedBanner =
+ !!featureFlags[FEATURE_FLAGS.DATA_MODELING_SUSPEND_FAILING_NODES] &&
+ !!suspension &&
+ !!savedQuery.is_materialized
+
return (
<div className="overflow-auto" data-attr="materialization-status-panel">
<div className="flex flex-col flex-1 gap-4">
@@ -188,12 +205,37 @@ export function MaterializationStatusPanel({ viewId, kind = 'view' }: Materializ
</Tooltip>
)}
</div>
+ {showSuspendedBanner && suspension && (
+ <LemonBanner
+ type="error"
+ className="mt-2"
+ action={{
+ children: 'Resume',
+ onClick: () => resumeMaterialization(),
+ loading: resumingMaterialization,
+ disabledReason: materializationAccessReason || undefined,
+ tooltip: 'If the query keeps failing, it will pause again.',
+ }}
+ >
+ <div data-attr="materialization-suspended-banner">
+ <div>
+ Scheduled runs are paused for this {kind === 'endpoint' ? 'endpoint' : 'view'}{' '}
+ because materialization kept failing. Fix the query, then resume.
+ </div>
+ <Tooltip title={suspension.reason} interactive>
+ <div className="mt-1 text-xs font-normal line-clamp-2">
+ Paused {humanFriendlyDetailedTime(suspension.at)} · {suspension.reason}
+ </div>
+ </Tooltip>
+ </div>
+ </LemonBanner>
+ )}
<div>
{savedQuery?.is_materialized ? (
<div>
{savedQuery?.last_run_at ? (
`Last run at ${humanFriendlyDetailedTime(savedQuery?.last_run_at)}`
- ) : (
+ ) : showSuspendedBanner ? null : (
<div>
<span>Materialization scheduled</span>
</div>
diff --git a/frontend/src/scenes/data-warehouse/saved_queries/materializationJobsLogic.ts b/frontend/src/scenes/data-warehouse/saved_queries/materializationJobsLogic.ts
index 67a98bd41f2e..b66eeb0ba631 100644
--- a/frontend/src/scenes/data-warehouse/saved_queries/materializationJobsLogic.ts
+++ b/frontend/src/scenes/data-warehouse/saved_queries/materializationJobsLogic.ts
@@ -14,10 +14,14 @@ import {
} from 'kea'
import { loaders } from 'kea-loaders'
-import api, { PaginatedResponse } from 'lib/api'
+import { lemonToast } from '@posthog/lemon-ui'
+
+import api, { ApiConfig, PaginatedResponse } from 'lib/api'
import { DataModelingJob, DataWarehouseSavedQuery } from '~/types'
+import { warehouseSavedQueriesResumeCreate } from 'products/data_warehouse/frontend/generated/api'
+
import type { CountedPaginatedResponse } from '../../../lib/api'
import { dataWarehouseViewsLogic } from './dataWarehouseViewsLogic'
@@ -33,6 +37,7 @@ export interface materializationJobsLogicValues {
dataModelingJobs: PaginatedResponse<DataModelingJob> | null
dataModelingJobsLoading: boolean
hasMoreJobsToLoad: boolean
+ resumingMaterialization: boolean
savedQuery: DataWarehouseSavedQuery | null
savedQueryLoading: boolean
startingMaterialization: boolean
@@ -112,6 +117,12 @@ export interface materializationJobsLogicActions {
savedQuery: DataWarehouseSavedQuery | null
payload?: any
}
+ resumeMaterialization: () => {
+ value: true
+ }
+ setResumingMaterialization: (resuming: boolean) => {
+ resuming: boolean
+ }
setStartingMaterialization: (starting: boolean) => {
starting: boolean
}
@@ -141,6 +152,8 @@ export const materializationJobsLogic = kea<materializationJobsLogicType>([
})),
actions({
setStartingMaterialization: (starting: boolean) => ({ starting }),
+ resumeMaterialization: true,
+ setResumingMaterialization: (resuming: boolean) => ({ resuming }),
}),
loaders(({ values, props }) => ({
savedQuery: [
@@ -182,6 +195,13 @@ export const materializationJobsLogic = kea<materializationJobsLogicType>([
],
})),
reducers({
+ resumingMaterialization: [
+ false,
+ {
+ resumeMaterialization: () => true,
+ setResumingMaterialization: (_, { resuming }: { resuming: boolean }) => resuming,
+ },
+ ],
startingMaterialization: [
false,
{
@@ -221,6 +241,20 @@ export const materializationJobsLogic = kea<materializationJobsLogicType>([
}
}),
listeners(({ actions, cache, props }) => ({
+ resumeMaterialization: async () => {
+ try {
+ await warehouseSavedQueriesResumeCreate(String(ApiConfig.getCurrentTeamId()), props.viewId)
+ lemonToast.success('Materialization resumed. The next scheduled run will include this view.')
+ actions.loadSavedQuery()
+ actions.loadDataModelingJobs()
+ } catch {
+ lemonToast.error(
+ "Couldn't resume materialization. Try again, and contact support if it keeps happening."
+ )
+ } finally {
+ actions.setResumingMaterialization(false)
+ }
+ },
updateDataWarehouseSavedQuerySuccess: ({ payload }) => {
// The sync frequency dropdown mutates this saved query through dataWarehouseViewsLogic, which
// doesn't own our `savedQuery`. Reload it so the displayed frequency reflects the new value
diff --git a/frontend/src/types.ts b/frontend/src/types.ts
index 82fa26883ce1..b3a35637dbff 100644
--- a/frontend/src/types.ts
+++ b/frontend/src/types.ts
@@ -81,6 +81,7 @@ import type {
import { QueryContext } from '~/queries/types'
import { AlertType } from 'products/alerts/frontend/types'
+import type { DataWarehouseSavedQueryApiSuspended } from 'products/data_warehouse/frontend/generated/api.schemas'
import type { ExperimentFeatureFlagInputApi } from 'products/experiments/frontend/generated/api.schemas'
import type { InsightFilterOverrideContextApi } from 'products/product_analytics/frontend/generated/api.schemas'
import type { AIPromptConfigApi } from 'products/subscriptions/frontend/generated/api.schemas'
@@ -6150,6 +6151,8 @@ export interface DataWarehouseSavedQuery {
latest_error: string | null
latest_history_id?: string
is_materialized?: boolean
+ /** Engine → suspension details. Only included when fetching a single saved query, not in list responses */
+ suspended?: DataWarehouseSavedQueryApiSuspended
upstream_dependency_count?: number
downstream_dependency_count?: number
created_at?: string
diff --git a/products/data_modeling/backend/facade/api.py b/products/data_modeling/backend/facade/api.py
index 42f02a38f8f0..a55dffbfdc3c 100644
--- a/products/data_modeling/backend/facade/api.py
+++ b/products/data_modeling/backend/facade/api.py
@@ -32,6 +32,7 @@ _LAZY = {
"resume_saved_query": "logic.node_suspension",
"suspension_reset_at": "logic.node_suspension",
"suspension_state": "logic.node_suspension",
+ "suspension_state_for_saved_query": "logic.node_suspension",
"compute_enrichment_hash": "logic.enrich_view_semantics",
"enrichment_gates_pass": "logic.enrich_view_semantics",
"enrich_view_semantics_sync": "logic.enrich_view_semantics",
diff --git a/products/data_modeling/backend/logic/node_suspension.py b/products/data_modeling/backend/logic/node_suspension.py
index 967d0a576831..bddd11af56a4 100644
--- a/products/data_modeling/backend/logic/node_suspension.py
+++ b/products/data_modeling/backend/logic/node_suspension.py
@@ -111,6 +111,21 @@ def resume_nodes(nodes: Iterable[Node], *, by: str, engine: str | None = None) -
)
+def suspension_state_for_saved_query(saved_query: "DataWarehouseSavedQuery") -> dict[str, dict]:
+ """Merged per-engine suspension state across every node backing the query.
+
+ When duplicate DAGs give the query several nodes, the earliest suspension per engine wins —
+ that is when the model actually stopped updating.
+ """
+ merged: dict[str, dict] = {}
+ for node in Node.objects.filter(team_id=saved_query.team_id, saved_query_id=saved_query.id):
+ for engine, entry in suspension_state(node).items():
+ existing = merged.get(engine)
+ if existing is None or (entry.get("at") or "") < (existing.get("at") or ""):
+ merged[engine] = entry
+ return merged
+
+
def resume_saved_query(saved_query: "DataWarehouseSavedQuery", *, by: str = "api") -> int:
"""One query can back several nodes when it landed in duplicate DAGs, and "resume this model"
means all of them."""
diff --git a/products/data_warehouse/backend/presentation/views/saved_query.py b/products/data_warehouse/backend/presentation/views/saved_query.py
index b32870d7ef5b..bdd4c5ac2203 100644
--- a/products/data_warehouse/backend/presentation/views/saved_query.py
+++ b/products/data_warehouse/backend/presentation/views/saved_query.py
@@ -333,6 +333,12 @@ class DataWarehouseSavedQueryMinimalSerializer(
read_only_fields = fields
+class SavedQuerySuspensionSerializer(serializers.Serializer):
+ at = serializers.DateTimeField(help_text="When materialization was suspended.")
+ reason = serializers.CharField(help_text="Error from the materialization run that tripped suspension.")
+ job_id = serializers.CharField(help_text="Materialization job that tripped suspension.")
+
+
class DataWarehouseSavedQuerySerializer(
DataWarehouseSavedQuerySerializerMixin, UserAccessControlSerializerMixin, serializers.ModelSerializer
):
@@ -369,6 +375,7 @@ class DataWarehouseSavedQuerySerializer(
latest_history_id = serializers.SerializerMethodField(read_only=True)
last_run_at = serializers.SerializerMethodField(read_only=True)
managed_viewset_kind = serializers.SerializerMethodField(read_only=True)
+ suspended = serializers.SerializerMethodField(read_only=True)
folder_id = TeamScopedPrimaryKeyRelatedField(
source="folder",
queryset=DataWarehouseSavedQueryFolder.objects.all(),
@@ -429,6 +436,7 @@ class DataWarehouseSavedQuerySerializer(
"is_test",
"expires_at",
"user_access_level",
+ "suspended",
]
read_only_fields = [
"id",
@@ -446,6 +454,7 @@ class DataWarehouseSavedQuerySerializer(
"is_materialized",
"origin",
"expires_at",
+ "suspended",
]
extra_kwargs = {
"soft_update": {"write_only": True},
@@ -486,6 +495,21 @@ class DataWarehouseSavedQuerySerializer(
return None
+ @extend_schema_field(
+ serializers.DictField(
+ child=SavedQuerySuspensionSerializer(),
+ help_text="Engines this query's materialization is suspended for after repeated failures. "
+ "Suspended engines are skipped by scheduled runs until the query is resumed.",
+ )
+ )
+ def get_suspended(self, view: DataWarehouseSavedQuery) -> dict[str, Any]:
+ from products.data_modeling.backend.facade.api import suspension_state_for_saved_query
+
+ return {
+ engine: SavedQuerySuspensionSerializer(entry).data
+ for engine, entry in suspension_state_for_saved_query(view).items()
+ }
+
def create(self, validated_data):
validated_data["team_id"] = self.context["team_id"]
validated_data["created_by"] = self.context["request"].user
diff --git a/products/data_warehouse/backend/tests/api/test_saved_query.py b/products/data_warehouse/backend/tests/api/test_saved_query.py
index b98fcf9173d3..6776037c3212 100644
--- a/products/data_warehouse/backend/tests/api/test_saved_query.py
+++ b/products/data_warehouse/backend/tests/api/test_saved_query.py
@@ -2,6 +2,7 @@ import uuid
from datetime import timedelta
from typing import Any, cast
+from freezegun import freeze_time
from posthog.test.base import APIBaseTest
from unittest import mock
from unittest.mock import AsyncMock, patch
@@ -1936,6 +1937,37 @@ class TestSavedQuery(APIBaseTest):
self.assertIn("Running", returned_statuses)
self.assertIn("Cancelled", returned_statuses)
+ def test_retrieve_exposes_earliest_suspension_across_nodes(self):
+ saved_query = DataWarehouseSavedQuery.objects.create(
+ team=self.team,
+ name="suspended_view_read",
+ query={"kind": "HogQLQuery", "query": "select event as event from events LIMIT 100"},
+ created_by=self.user,
+ )
+ nodes = [
+ Node.objects.create(
+ team=self.team,
+ dag=DAG.objects.create(team=self.team, name=f"read_dag_{i}"),
+ saved_query=saved_query,
+ type=NodeType.MAT_VIEW,
+ )
+ for i in range(2)
+ ]
+ with freeze_time("2026-07-01T00:00:00Z"):
+ mark_node_suspended(nodes[0], engine="clickhouse", reason="first failure", job_id="job-1")
+ with freeze_time("2026-07-02T00:00:00Z"):
+ mark_node_suspended(nodes[1], engine="clickhouse", reason="later failure", job_id="job-2")
+ for node in nodes:
+ node.save()
+
+ response = self.client.get(f"/api/environments/{self.team.id}/warehouse_saved_queries/{saved_query.id}/")
+
+ self.assertEqual(response.status_code, 200)
+ suspended = response.json()["suspended"]
+ self.assertEqual(list(suspended), ["clickhouse"])
+ self.assertEqual(suspended["clickhouse"]["reason"], "first failure")
+ self.assertEqual(suspended["clickhouse"]["job_id"], "job-1")
+
def test_resume_clears_suspension_for_every_node_of_the_query(self):
# Key access is the point of this surface: the node-level resume is on an INTERNAL viewset,
# which no API key can reach.
diff --git a/products/data_warehouse/frontend/generated/api.schemas.ts b/products/data_warehouse/frontend/generated/api.schemas.ts
index 81f9adeff709..0aafccde5870 100644
--- a/products/data_warehouse/frontend/generated/api.schemas.ts
+++ b/products/data_warehouse/frontend/generated/api.schemas.ts
@@ -892,6 +892,20 @@ export type DataWarehouseSavedQueryApiQuery = {
export type DataWarehouseSavedQueryApiColumnsItem = { [key: string]: unknown }
+export interface SavedQuerySuspensionApi {
+ /** When materialization was suspended. */
+ at: string
+ /** Error from the materialization run that tripped suspension. */
+ reason: string
+ /** Materialization job that tripped suspension. */
+ job_id: string
+}
+
+/**
+ * Engines this query's materialization is suspended for after repeated failures. Suspended engines are skipped by scheduled runs until the query is resumed.
+ */
+export type DataWarehouseSavedQueryApiSuspended = { [key: string]: SavedQuerySuspensionApi }
+
/**
* * `never` - never
* * `15min` - 15min
@@ -1017,6 +1031,8 @@ export interface DataWarehouseSavedQueryApi {
* @nullable
*/
readonly user_access_level: string | null
+ /** Engines this query's materialization is suspended for after repeated failures. Suspended engines are skipped by scheduled runs until the query is resumed. */
+ readonly suspended: DataWarehouseSavedQueryApiSuspended
}
export type PatchedDataWarehouseSavedQueryApiQueryKind =
@@ -1036,6 +1052,11 @@ export type PatchedDataWarehouseSavedQueryApiQuery = {
export type PatchedDataWarehouseSavedQueryApiColumnsItem = { [key: string]: unknown }
+/**
+ * Engines this query's materialization is suspended for after repeated failures. Suspended engines are skipped by scheduled runs until the query is resumed.
+ */
+export type PatchedDataWarehouseSavedQueryApiSuspended = { [key: string]: SavedQuerySuspensionApi }
+
/**
* Shared methods for DataWarehouseSavedQuery serializers.
*
@@ -1135,6 +1156,8 @@ export interface PatchedDataWarehouseSavedQueryApi {
* @nullable
*/
readonly user_access_level?: string | null
+ /** Engines this query's materialization is suspended for after repeated failures. Suspended engines are skipped by scheduled runs until the query is resumed. */
+ readonly suspended?: PatchedDataWarehouseSavedQueryApiSuspended
}
export interface SavedQueryResumeApi {
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index 86e0b5361bcc..6ce10ab669d9 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -16617,6 +16617,20 @@ export namespace Schemas {
export type DataWarehouseSavedQueryColumnsItem = { [key: string]: unknown };
+ export interface SavedQuerySuspension {
+ /** When materialization was suspended. */
+ at: string;
+ /** Error from the materialization run that tripped suspension. */
+ reason: string;
+ /** Materialization job that tripped suspension. */
+ job_id: string;
+ }
+
+ /**
+ * Engines this query's materialization is suspended for after repeated failures. Suspended engines are skipped by scheduled runs until the query is resumed.
+ */
+ export type DataWarehouseSavedQuerySuspended = {[key: string]: SavedQuerySuspension};
+
/**
* * `never` - never
* * `15min` - 15min
@@ -16774,6 +16788,8 @@ export namespace Schemas {
* @nullable
*/
readonly user_access_level: string | null;
+ /** Engines this query's materialization is suspended for after repeated failures. Suspended engines are skipped by scheduled runs until the query is resumed. */
+ readonly suspended: DataWarehouseSavedQuerySuspended;
}
/**
@@ -48482,6 +48498,11 @@ export namespace Schemas {
export type PatchedDataWarehouseSavedQueryColumnsItem = { [key: string]: unknown };
+ /**
+ * Engines this query's materialization is suspended for after repeated failures. Suspended engines are skipped by scheduled runs until the query is resumed.
+ */
+ export type PatchedDataWarehouseSavedQuerySuspended = {[key: string]: SavedQuerySuspension};
+
/**
* Shared methods for DataWarehouseSavedQuery serializers.
*
@@ -48581,6 +48602,8 @@ export namespace Schemas {
* @nullable
*/
readonly user_access_level?: string | null;
+ /** Engines this query's materialization is suspended for after repeated failures. Suspended engines are skipped by scheduled runs until the query is resumed. */
+ readonly suspended?: PatchedDataWarehouseSavedQuerySuspended;
}
/**