Skip to content

Flink: Add operator to expire snapshots - #3255

Closed
myandpr wants to merge 2 commits into
apache:mainfrom
myandpr:flink-auto-expire-snapshot
Closed

myandpr wants to merge 2 commits into
apache:mainfrom
myandpr:flink-auto-expire-snapshot

Conversation

@myandpr

@myandpr myandpr commented Oct 8, 2021

Copy link
Copy Markdown
Contributor

What problem does this pr solved?

when we write data into icebeg table using flink, it will produce a lot of small files.
Merely compacting small files cannot reduce the number of small files.
Only after compacting the small files and deleting expired snapshot files can we really reduce the number of small files overall.

This branch supports deleting expired snapshots automatically when writing data into iceberg table in flink.

How was this problem solved?

We added the following configuration

// auto expire snapshots
snapshot.flink.auto-expire.enabled
snapshot.flink.auto-expire.interval-ms
snapshot.flink.auto-expire.max-snapshot-age-ms
snapshot.flink.auto-expire.min-snapshots-to-keep
snapshot.flink.auto-expire.snapshots-group-nums

In this PR, we add 2 operators(ExpireSnapshotGenerator, ExpireSnapshotOperator) for expire snapshots function after IcebergFilesCommitter.

expire snapshot function:

  1. In IcebergFilesCommitter.notifyCheckpointComplete(), we emit a 'EndCheckpoint' message to downstream operator 'ExpireSnapshotGenerator'.
  2. 'ExpireSnapshotGenerator' generates all files(manifest list file, menifest file, data file) that needs to be deleted and distributes them to downstream operator 'ExpireSnapshotOperator'.
  3. 'ExpireSnapshotOperator' start to actually delete all files received from upstream in parallel.

@rdblue

rdblue commented Oct 10, 2021

Copy link
Copy Markdown
Contributor

@myandpr, I have a few questions about the approach of this PR. First, what is the use case that motivates having separate configuration for this rather than using the existing config for snapshot expiration? I think that snapshot expiration policy and processes that actually perform the expiration are two orthogonal things. If you want to run expiration from Flink, that makes sense. But expiring snapshots differently when running in Flink vs some other method seems incorrect to me.

Second, how are you identifying the files to delete? There are two methods, incremental and reachability based. Incremental is no longer our recommended way of cleaning up files because it is really hard to reason about certain cases when snapshots are cherry-picked across branches. It isn't necessarily bad to continue using it here, but we should consider whether we can improve it. For example, I think this only cares about expiring snapshots in the current table state, which is an easier problem. Maybe we can extend the operation to support that more directly and avoid some of the hard cases.

@rdblue rdblue changed the title [Iceberg] Flink:auto delete expired snapshots Flink: Add operator to expire snapshots Oct 10, 2021
@zhaofuw

zhaofuw commented Mar 20, 2023

Copy link
Copy Markdown

May I ask whether this plan will continue to be promoted?

@github-actions

Copy link
Copy Markdown

This pull request has been marked as stale due to 30 days of inactivity. It will be closed in 1 week if no further activity occurs. If you think that’s incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the PR at any time and @mention a reviewer or discuss it on the [email protected] list. Thank you for your contributions.

@github-actions github-actions Bot added the stale label Jul 28, 2024
@github-actions

github-actions Bot commented Aug 5, 2024

Copy link
Copy Markdown

This pull request has been closed due to lack of activity. This is not a judgement on the merit of the PR in any way. It is just a way of keeping the PR queue manageable. If you think that is incorrect, or the pull request requires review, you can revive the PR at any time.

@github-actions github-actions Bot closed this Aug 5, 2024
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.

3 participants