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): pre-create all clickhouse kafka engine topics in person-state-batch test (#63037)

José Sequeira104d89b0bca1
diff --git a/nodejs/tests/worker/ingestion/person-state-batch.test.ts b/nodejs/tests/worker/ingestion/person-state-batch.test.ts
index 5e2e750392ae..18fad705141c 100644
--- a/nodejs/tests/worker/ingestion/person-state-batch.test.ts
+++ b/nodejs/tests/worker/ingestion/person-state-batch.test.ts
@@ -11,6 +11,7 @@ import { PipelineResultType, isDlqResult, isOkResult, isRedirectResult } from '~
import { KafkaProducerWrapper } from '~/kafka/producer'
import { PluginEvent, Properties } from '~/plugin-scaffold'
import { Clickhouse } from '~/tests/helpers/clickhouse'
+import { ensureKafkaTopics } from '~/tests/helpers/kafka'
import { fromInternalPerson } from '~/worker/ingestion/persons/person-update-batch'
import { PersonsStore } from '~/worker/ingestion/persons/persons-store'
@@ -169,6 +170,11 @@ describe('PersonState.processEvent()', () => {
mockProducerObserver.resetKafkaProducer()
clickhouse = Clickhouse.create()
+ // Pre-create every topic ClickHouse's Kafka engine tables subscribe to. Otherwise any
+ // table whose topic is missing keeps retrying "Can't get assignment", which saturates
+ // ClickHouse's background scheduler and intermittently starves the consumers this suite
+ // waits on via delayUntilEventIngested — flaky timeouts in CI.
+ await ensureKafkaTopics(await clickhouse.getKafkaEngineTopics())
await clickhouse.exec('SYSTEM STOP MERGES')
organizationId = await createOrganization(hub.postgres)