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(ingestion): retry transient persons-Postgres failures in batch steps (#61399)

Paweł Ledwońf55ff1d1adbb
diff --git a/nodejs/src/ingestion/analytics/post-team-preprocessing-subpipeline.ts b/nodejs/src/ingestion/analytics/post-team-preprocessing-subpipeline.ts
index 2dd43fe157a6..9bd960456413 100644
--- a/nodejs/src/ingestion/analytics/post-team-preprocessing-subpipeline.ts
+++ b/nodejs/src/ingestion/analytics/post-team-preprocessing-subpipeline.ts
@@ -96,10 +96,18 @@ export function createPostTeamPreprocessingSubpipeline<TInput extends PostTeamPr
.pipeBatch(createOnlyCookielessRateLimitToOverflowStep(preservePartitionLocality, overflowRedirectService))
// Refresh TTLs for overflow lane events (keeps Redis flags alive)
.pipeBatch(createOverflowLaneTTLRefreshStep(overflowLaneTTLRefreshService))
- // Prefetch must run after cookieless, as cookieless changes distinct IDs
- .pipeBatch(prefetchPersonsStep(personsStore, personsPrefetchEnabled))
+ // Prefetch must run after cookieless, as cookieless changes distinct IDs.
+ // Retry transient persons-Postgres failures (e.g. PgBouncer scale-down) instead
+ // of letting them crash the consumer loop.
+ .pipeBatchWithRetry(prefetchPersonsStep(personsStore, personsPrefetchEnabled), {
+ tries: 3,
+ sleepMs: 100,
+ })
// Batch insert personless distinct IDs after prefetch (uses prefetch cache)
- .pipeBatch(processPersonlessDistinctIdsBatchStep(personsStore, personsPrefetchEnabled))
+ .pipeBatchWithRetry(processPersonlessDistinctIdsBatchStep(personsStore, personsPrefetchEnabled), {
+ tries: 3,
+ sleepMs: 100,
+ })
// Prefetch hog functions for all teams in the batch
.pipeBatch(createPrefetchHogFunctionsStep(hogTransformer, cdpHogWatcherSampleRate))
)