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 postgres-parity test (#62839)

José Sequeira1500b42ae54f
diff --git a/nodejs/tests/worker/ingestion/postgres-parity.test.ts b/nodejs/tests/worker/ingestion/postgres-parity.test.ts
index 8fb98a020c0c..d372232c968d 100644
--- a/nodejs/tests/worker/ingestion/postgres-parity.test.ts
+++ b/nodejs/tests/worker/ingestion/postgres-parity.test.ts
@@ -36,12 +36,18 @@ function createPersonOutputs(kafkaProducer: KafkaProducerWrapper) {
})
}
/**
- * After topic creation/recreation, ClickHouse Kafka engine consumers need to connect.
- * With auto.offset.reset=latest, messages produced before connection are missed.
- * We produce probe messages until ClickHouse consumes one, guaranteeing the
- * consumer is active before tests begin.
+ * Waits until ClickHouse's Kafka engine is consuming the person topic, by producing probe
+ * messages until one lands in the person table.
+ *
+ * Before probing we 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 person consumer this suite
+ * depends on — the root cause of the flakiness. We repeatedly produce probe messages because,
+ * with the default auto.offset.reset=latest, messages produced before assignment are missed.
*/
async function waitForClickHousePersonConsumer(clickhouse: Clickhouse): Promise<void> {
+ await ensureKafkaTopics(await clickhouse.getKafkaEngineTopics(), extraServerConfig)
+
const producer = await KafkaProducerWrapper.create(undefined)
const probeTeamId = -1