Partition Finalization in Pint... Note

Partition Finalization in Pinterest’s Next-Generation DB Ingestion Framework

This post introduces a solution for determining when data is sufficiently complete for downstream consumption in Pinterest's new database ingestion framework. The framework, built on technologies like Kafka, Flink, and Iceberg, processes data continuously, posing a challenge for batch jobs that previously relied on single-run batch jobs for finalization. Time-partitioned data, grouped by time columns, allows consumers to read specific slices without scanning entire tables. In batch systems, a partition was considered final once the producer finished writing; however, the streaming framework continuously writes to partitions, making traditional finalization difficult. To address this, Pinterest developed an event-time-based partition finalization mechanism within the Flink-to-Iceberg sink. This system extracts event times from records, collects statistics like minimum and maximum event times between Flink checkpoints, and stores these in Iceberg's snapshot summaries. An algorithm then uses these statistics to generate a watermark, indicating the point up to which a partition is considered complete, ensuring it always increases. This watermark is stored as an Iceberg table property, allowing downstream jobs to query it for processing triggers. The mechanism is propagated to base tables by the upsert job, ensuring the signal travels with the data. The implementation leverages extensible Iceberg-Flink sink capabilities: accumulators collect record statistics in writer subtasks, and commit processors execute custom logic before and after Iceberg commits. This design allows for zero overhead when extensions are not configured and ensures that partition finalization is efficiently integrated into the streaming data pipeline.
CdXz5zHNQW_u1wkB0MUto.png