apache / apache/iceberg-python

[Feature] Add Support for Distributed Write

オープン
#1,751 コメント 12 件 リアクション 7 件 担当者 0 名 GitHub で見る
主要言語
Python
スター
1.1k
フォーク
581
平均マージ
1日 17時間
マージ済み PR(30日)
78

説明

### Feature Request / Improvement

## Problem Statement
A key problem in distributed Iceberg systems is that commit processes can block each other when multiple workers try to update table metadata simultaneously. This blocking creates a severe performance bottleneck that limits throughput, particularly in high-volume ingestion scenarios.

## Use Case
In our distributed architecture:
1. Process A writes Parquet files in Iceberg-compatible format
2. Simple string identifiers (file paths) need to be passed between systems
3. Process B takes these strings and commits the files to make them visible in queries

This pattern is especially useful for high-concurrency ingestion scenarios where multiple writers could be writing data to an Iceberg table simultaneously, but we want to centralize and coordinate the commit process. This approach is critical because in distributed environments, commit processes can block each other, creating a significant bottleneck in high-throughput scenarios.

### Detailed Workflow
Our workflow involves:

```python
# Process A: Write data but don't commit
table = catalog.load_table(identifier="iceberg.table")
data_files = list(pyiceberg.io.pyarrow._dataframe_to_data_files(
table_metadata=table.metadata, write_uuid=uuid.uuid4(), df=pa_df, io=table.io
)
)

queue.send(data_files) # Send data_files strings to queue system

# Process B: Commit processor (runs separately)
data_files = queue.receive()
with table.transaction() as trx:
with trx.update_snapshot().fast_append() as update_snapshot:
for data_file in data_files:
update_snapshot.append_data_file(data_file)
```

This separation of write and commit operations provides several advantages:
- Improved throughput by parallelizing write operations across multiple workers
- Reduced lock contention since metadata commits (which require locks) are centralized
- Better failure handling - failed writes don't impact the table state
- Controlled transaction timing - commits can be batched or scheduled optimally
- Elimination of commit process blocking - by centralizing commits, we prevent distributed writers from blocking each other during metadata updates, which is a major performance bottleneck

## Current Limitations
- Serializing `DataFile` objects between processes is challenging
- We've attempted custom serialization with compression (gzip, zlib), which is working however required long complex code
- Using `jsonpickle` also presented significant problems

## Proposed Solution
We're seeking a robust way to handle distributed writes, potentially with:

1. Add serialization/deserialization methods to the `DataFile` class
2. Support Avro for efficient serialization of `DataFile` objects (potentially smaller than other approaches)
3. Better integration with `append_data_file` API
4. OR a more accessible way to use the ManifestFile functionality that's already implemented in PyIceberg

Ideally, the solution would:
- Handle schema evolution gracefully (unlike current `add_files` approach which has issues when schema changes)
- Work efficiently with minimal overhead for large-scale concurrent processing
- Provide simple primitives that can be used in distributed systems without requiring complex serialization
- Follow patterns similar to those used in the Java implementation where appropriate

## Alternative Approaches Tried
- We've implemented a custom serialization/deserialization function with compression
- We explored the approach in #1678, but found it created too many commits and became a performance bottleneck

## Related PRs/Issues
- PR #1742 (closed): Original attempt at write_parquet API
- Issue #1737 (closed): Feature request for Table-Compatible Parquet Files
- Issue #1678: Related implementation suggestion

We're looking for guidance on the best approach to solve this distributed writing pattern while maintaining performance and schema compatibility.

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

調査の方向性

まず、DataFile と ManifestFile の機能、append_data_file API、および workflow に示されている _dataframe_to_data_files エントリーポイントを読んでください。issue #1678 とクローズされた PR #1742 を確認し、以前のアプローチと、それらの commit またはシリアライゼーションに関する問題を理解してください。最終的には、スキーマ互換性を維持し、データファイルを渡して commit するためのシンプルなプリミティブを提供する、方針の定まった効率的な分散書き込みパスにしてください。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
python
領域
data-engineering, distributed-systems
issue の種類
機能追加
難易度
5/5
見積もり時間
1週間以上
活発さ
静か
明瞭さ
説明が足りない
初心者へのやさしさ
28/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。