: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
feat(experiments): add ttl verdict banner to staff cache health tab (#96526)
Juraj Majerikeb2376413629
diff --git a/frontend/src/scenes/experiments/staff/CacheHealth.tsx b/frontend/src/scenes/experiments/staff/CacheHealth.tsxindex 108a5c9bb792..bddfe0ac57d3 100644--- a/frontend/src/scenes/experiments/staff/CacheHealth.tsx+++ b/frontend/src/scenes/experiments/staff/CacheHealth.tsx@@ -5,6 +5,7 @@ import { TimeSeriesBarChart } from '@posthog/quill-charts'import { useChartTheme } from 'lib/charts/hooks'import { dayjs } from 'lib/dayjs'+import { LemonBanner } from 'lib/lemon-ui/LemonBanner'import { LemonCard } from 'lib/lemon-ui/LemonCard'import { LemonSkeleton } from 'lib/lemon-ui/LemonSkeleton'import { LemonTable, LemonTableColumns } from 'lib/lemon-ui/LemonTable'@@ -40,6 +41,46 @@ function ttlStatus(partition: string): { label: string; type: LemonTagType } {return { label: `Drops in ${days}d`, type: 'muted' }}+// The tables self-clean only while TTL merges keep dropping expired partitions. Any partition+// dated before today means that stopped, so it gets a headline verdict instead of a table row+// the reader has to scan for.+function TtlVerdictBanner({ tables }: { tables: CacheTableStats[] }): JSX.Element | null {+ if (tables.length === 0) {+ return null+ }+ const readable = tables.filter((table) => !table.unavailable)+ const unavailable = tables.filter((table) => table.unavailable)+ const today = dayjs().format('YYYYMMDD')+ const expired = readable.flatMap((table) => table.partitions.filter((partition) => partition.partition < today))+ if (expired.length > 0) {+ const days = new Set(expired.map((partition) => partition.partition))+ const bytes = expired.reduce((sum, partition) => sum + partition.bytes_on_disk, 0)+ const oldest = [...days].sort()[0]+ return (+ <LemonBanner type="error" className="mb-4">+ Expired data from {days.size} {days.size === 1 ? 'day' : 'days'} ({humanizeBytes(bytes)}) is still on+ disk, oldest from {formatPartitionDay(oldest)}. ClickHouse is not dropping expired partitions. Check TTL+ merges on the cluster.+ </LemonBanner>+ )+ }+ // A green verdict from partial data would hide the exact failure it exists to surface,+ // so an unreadable table degrades the verdict to unknown.+ if (unavailable.length > 0) {+ return (+ <LemonBanner type="warning" className="mb-4">+ TTL status is unknown for {unavailable.map((table) => tableLabel(table.table)).join(' and ')}:+ system.parts could not be read. No expired data in the tables that were checked.+ </LemonBanner>+ )+ }+ return (+ <LemonBanner type="success" className="mb-4">+ TTL cleanup is keeping up. No expired data is waiting to be dropped.+ </LemonBanner>+ )+}+// "experiment_exposures_preaggregated" -> "exposures" — the key the backend uses for growth series// (it comes from the experiment_precompute_table query tag on build INSERTs).const growthKey = (table: string): string => table.replace(/^experiment_/, '').replace(/_preaggregated$/, '')@@ -212,6 +253,7 @@ export function CacheHealth(): JSX.Element {</LemonButton></div></div>+ {cacheHealth ? <TtlVerdictBanner tables={tables} /> : null}<div className="flex flex-wrap gap-4 mb-4">{!cacheHealth && cacheHealthLoading? [0, 1].map((i) => (