This article details Pinterest's solution for robust partition finalization within their next-generation, stream-based database ingestion framework built on Kafka, Flink, Spark, and Iceberg. It addresses the challenge of determining data completeness in a continuous streaming environment, where traditional batch-based finalization is no longer applicable. The solution leverages event-time watermarks and extensible Flink-to-Iceberg sink mechanisms to provide reliable signals for downstream consumers.
Read original on Pinterest EngineeringIn traditional batch processing, data completeness (or "finalization") for a time-partitioned dataset is straightforward: once a batch job finishes writing all data for a specific time window, that partition is considered final. However, in stream-based ingestion systems, especially when dealing with change data capture (CDC) and potentially late-arriving events, a partition can continuously receive updates long after its wall-clock time has passed. This makes it challenging for downstream consumers, such as batch analytics jobs that run only once per hour, to know when a partition is truly complete and stable enough to process without missing data. The article highlights how Pinterest's migration to a stream-based ingestion framework necessitated a new, unified mechanism to infer this finalization state.
Pinterest introduced an event-time based partition finalization mechanism directly into their streaming pipeline. This solution is integrated with the Flink job responsible for writing CDC events to Iceberg tables. The core idea is to measure the progress of event time within the stream and publish a finalization watermark directly into the Iceberg table's metadata. This allows downstream consumers to query the metadata and wait for the watermark to advance past their target partition before initiating processing.
Metadata-Driven Finalization
The elegance of this solution lies in its metadata-driven approach. By embedding finalization signals directly into Iceberg's metadata (snapshot summaries and table properties), it avoids external services or side channels for coordination, simplifying propagation and consumption. The signal follows the data, even through transformations like upsert jobs from CDC tables to base tables.