Skip to content

[FLINK-40679][pipeline-connector/iceberg] Support Iceberg table maintenance - #4544

Open
zml1206 wants to merge 4 commits into
apache:masterfrom
zml1206:iceberg-maintenance
Open

zml1206 wants to merge 4 commits into
apache:masterfrom
zml1206:iceberg-maintenance

Conversation

@zml1206

@zml1206 zml1206 commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

What is the purpose of this pull request?

Add optional Iceberg table maintenance to CDC pipelines, supporting data file compaction, snapshot expiration, and orphan file cleanup.

Maintenance supports both existing target tables and tables created by CDC after startup. It is disabled by default and configured through sink.maintenance.*.

Brief change log

  • Integrate Iceberg’s TableMaintenance API into the Iceberg pipeline sink.
  • Add configurable maintenance triggers, retention settings, execution parallelism, and JDBC locking.
  • Automatically discover maintenance targets from captured source tables and pipeline routing for MySQL, PostgreSQL, Oracle, and SQL Server. Explicit target lists take precedence.
  • Allow maintenance to wait for target table creation while pipeline startup and checkpoints proceed.
  • Support maintenance execution and savepoint recovery on Flink 1.20 and Flink 2.2.
  • Add English and Chinese documentation for configuration, deployment requirements, and recovery constraints.

Verifying this change

This change added tests and can be verified as follows:

  • Added unit tests in MaintenanceOptionsTest, TargetTableDiscoveryTest, and MaintenanceGraphAdapterTest for configuration validation, routed target discovery, and topology adaptation.
  • Added source discovery tests in MySqlTableDiscoveryTest, PostgresTableDiscoveryTest, OracleTableDiscoveryTest, and SqlServerTableDiscoveryTest, covering capture filtering, table identifier conversion, source-specific options, JDBC error handling, and connection cleanup.
  • Added tests in MaintenanceRegressionTest, DeferredTableLoaderTest, and RefreshingTableLoaderTest covering resource cleanup, deferred table loading, and metadata freshness.
  • Added MiniCluster tests in TableMaintenanceExecutionTest covering CDC writes, all three maintenance operations, and savepoint recovery before and after target creation.
  • Verified maintenance and source discovery tests on both Flink 1.20 and Flink 2.2. Spotless and Checkstyle checks passed.

Documentation

  • Does this pull request introduce a new feature? Yes.
  • If yes, how is the feature documented? Docs: updated the English and Chinese Iceberg pipeline connector documentation.

Was generative AI tooling used to co-author this PR?
  • Yes

Generated-by: Codex GPT-6

…ance for CDC-created tables

Discover routed maintenance targets at submission and allow CDC to create
missing Iceberg tables after the job starts. Build the native TableMaintenance
topology and adapt initialization and catalog ownership before submission.

Support data-file rewriting, snapshot expiration, and orphan cleanup using
the configured FileIO, with Flink 1.20 and 2.2 compatibility.

Validation: 134 tests passed per Flink version, including MiniCluster
maintenance and savepoint recovery; formatting, Checkstyle, and package passed.

Local implementation checkpoint; assign a JIRA issue before opening a PR.

Generated-by: Codex GPT-6
…lization and simplify setup

Preserve the original FileIO implementation, properties, and effective Hadoop
configuration across metadata split JSON serialization. Retain prefix listing
and bulk deletion capabilities for native orphan cleanup.

Share task registration across maintenance builders and normalize discovered
targets in MaintenanceOptions. Clarify the discovery contract and cover the
Planner-to-Reader path and duplicate targets in regression tests.

Validation: 135 related tests passed on both Flink 1.20 / Java 11 and
Flink 2.2 / Java 17, including MiniCluster maintenance and savepoint recovery.
Package, Spotless, and Checkstyle passed.

Local development commit; assign a JIRA issue before opening a PR.

Generated-by: Codex GPT-6
… and use native FileIO

Refresh cached tables before native maintenance planners copy metadata, so
planning observes new commits and avoids reading expired manifest lists.

Use Iceberg's native FileIO serialization and remove the Hadoop configuration
wrapper and its dedicated tests. Consolidate the English and Chinese
maintenance documentation and describe the executor configuration requirement.

Validation: the new regression fails with NotFoundException before the fix.
All 72 selected maintenance tests pass on both Flink 1.20 and Flink 2.2,
including MiniCluster execution and savepoint recovery. Package, Spotless,
and Checkstyle checks passed.

Local development commit; assign a JIRA issue before opening a PR.

Generated-by: Codex GPT-6
…tion handling

Add PostgreSQL, Oracle, and SQL Server discovery tests using JDBC metadata
fixtures and the native dialect filtering paths. Cover table identifiers,
empty results, PostgreSQL options, and database filtering.

Distinguish runtime failures from SQLException handling at each query stage,
and verify connection cleanup and exception causes. Extract package-private
dialect creation methods to inject the test connections.

Validation: all 23 selected discovery tests pass on Flink 1.20 / Java 11
and Flink 2.2 / Java 17. Package, Spotless, and Checkstyle checks passed.

Generated-by: Codex GPT-6
@lvyanquan lvyanquan self-assigned this Sep 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants