-
Notifications
You must be signed in to change notification settings - Fork 3k
Flink: Maintenance - RewriteDataFiles #11497
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@aokolnychyi, @RussellSpitzer, @szehon-ho - I have touched the Spark compaction as well to remove duplicate code, and move it to the @stevenzwu: Could you please review the PR? |
|
Could we break this up into smaller PR's? I think just one for the refactoring of classes out of the Spark Module would be a good first step? |
Sure thing. I think for these refactors, it is important to see the whole picture as well, and it is always a tough decision to decide how it is easier to review. Will create the PR soon. |
|
IMHO just grouping into several commits would suffice, e.g. Core/Spark/Flink. Grouping into multiple PRs, might make this harder to test and review. |
|
Created #11513 for the refactoring part. I think it is a good start for the review, but drop me a message if you think we need to split the things further. |
|
Using the parameter io-impl: com.esotericsoftware.kryo.KryoException: java.lang.NullPointerException
Serialization trace:
s3 (org.apache.iceberg.aws.s3.S3FileIO)
io (org.apache.iceberg.SerializableTable)
table (org.apache.iceberg.flink.maintenance.operator.DataFileRewritePlanner$PlannedGroup)
at com.esotericsoftware.kryo.serializers.ObjectField.write(ObjectField.java:82)
at com.esotericsoftware.kryo.serializers.FieldSerializer.write(FieldSerializer.java:495)
at com.esotericsoftware.kryo.Kryo.writeObject(Kryo.java:523)
at com.esotericsoftware.kryo.serializers.ObjectField.write(ObjectField.java:61)
at com.esotericsoftware.kryo.serializers.FieldSerializer.write(FieldSerializer.java:495)
at com.esotericsoftware.kryo.Kryo.writeObject(Kryo.java:523)
at com.esotericsoftware.kryo.serializers.ObjectField.write(ObjectField.java:61)
at com.esotericsoftware.kryo.serializers.FieldSerializer.write(FieldSerializer.java:495)
at com.esotericsoftware.kryo.Kryo.writeClassAndObject(Kryo.java:599)
at org.apache.flink.api.java.typeutils.runtime.kryo.KryoSerializer.serialize(KryoSerializer.java:356)
...... |
|
@ygrzjh: Seems like an issue with the |
.../flink/src/main/java/org/apache/iceberg/flink/maintenance/operator/DeleteFilesProcessor.java
Show resolved
Hide resolved
flink/v1.20/flink/src/main/java/org/apache/iceberg/flink/maintenance/api/RewriteDataFiles.java
Outdated
Show resolved
Hide resolved
flink/v1.20/flink/src/main/java/org/apache/iceberg/flink/maintenance/api/RewriteDataFiles.java
Show resolved
Hide resolved
...nk/src/main/java/org/apache/iceberg/flink/maintenance/operator/DataFileRewriteCommitter.java
Outdated
Show resolved
Hide resolved
...nk/src/main/java/org/apache/iceberg/flink/maintenance/operator/DataFileRewriteCommitter.java
Outdated
Show resolved
Hide resolved
| private final RewriteFileGroup group; | ||
|
|
||
| private PlannedGroup( | ||
| SerializableTable table, int groupsPerCommit, long splitSize, RewriteFileGroup group) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wondering if SerializableTable can be passed to the DataFileRewriteExecutor just once during initialization (instead of per planned group)? how big is the serialized Table object?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DataFileRewriteExecutor input is rebalanced. It is not trivial to make sure that the table is sent to every instance.
The size of the serialized table is mostly dependent on the size of the FileIO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pass SerializableTable to the constructor of DataFileRewriteExecutor so that it becomes part of the class state.
if the planner needs more than a read-only table, maybe we can pass a TableLoader to the planner class and load a table that way?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need the current schema/spec for the table. If we pass the data at the constructor then we will work from old table metadata.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why don't we let the committer load the Table object via a TableLoader. Regular Table can be refreshed.
It is totally good if the PlannedGroup contains the snapshotId long. But I am a little concerned about including the whole SerializableTable over the Flink network stack for serialization. if unaligned checkpoint is enabled, we need to worry about serialization compatibility problem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need the info on the DataFileRewriteExecutor as well. That would mean Catalog connection/request from every writer.
TBH, I'm not too concerned about state compatibility. We only has to be very careful about silent issues. In other cases we could always drop the state and start the compaction again. We will not have any data loss if a maintenance task does not finish.
...link/src/main/java/org/apache/iceberg/flink/maintenance/operator/DataFileRewritePlanner.java
Outdated
Show resolved
Hide resolved
...link/src/main/java/org/apache/iceberg/flink/maintenance/operator/DataFileRewritePlanner.java
Outdated
Show resolved
Hide resolved
...link/src/main/java/org/apache/iceberg/flink/maintenance/operator/DataFileRewritePlanner.java
Show resolved
Hide resolved
...link/src/main/java/org/apache/iceberg/flink/maintenance/operator/DataFileRewritePlanner.java
Outdated
Show resolved
Hide resolved
...nk/src/main/java/org/apache/iceberg/flink/maintenance/operator/DataFileRewriteCommitter.java
Outdated
Show resolved
Hide resolved
...nk/src/main/java/org/apache/iceberg/flink/maintenance/operator/DataFileRewriteCommitter.java
Outdated
Show resolved
Hide resolved
...nk/src/main/java/org/apache/iceberg/flink/maintenance/operator/DataFileRewriteCommitter.java
Outdated
Show resolved
Hide resolved
| private final RewriteFileGroup group; | ||
|
|
||
| private PlannedGroup( | ||
| SerializableTable table, int groupsPerCommit, long splitSize, RewriteFileGroup group) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pass SerializableTable to the constructor of DataFileRewriteExecutor so that it becomes part of the class state.
if the planner needs more than a read-only table, maybe we can pass a TableLoader to the planner class and load a table that way?
...link/src/main/java/org/apache/iceberg/flink/maintenance/operator/DataFileRewritePlanner.java
Outdated
Show resolved
Hide resolved
691c61a to
997304c
Compare
|
#11131 changed how the delete files are removed. See: #11131 (comment) |
...nk/src/main/java/org/apache/iceberg/flink/maintenance/operator/DataFileRewriteCommitter.java
Outdated
Show resolved
Hide resolved
...nk/src/main/java/org/apache/iceberg/flink/maintenance/operator/DataFileRewriteCommitter.java
Outdated
Show resolved
Hide resolved
flink/v1.20/flink/src/main/java/org/apache/iceberg/flink/maintenance/api/RewriteDataFiles.java
Show resolved
Hide resolved
...link/src/main/java/org/apache/iceberg/flink/maintenance/operator/DataFileRewritePlanner.java
Show resolved
Hide resolved
| } | ||
|
|
||
| RewritePlanResult plan = | ||
| planner.plan( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so we are doing a full table scan to figure out the rewrite candidate, which can be expensive for large tables. wondering if incremental scan is a good fit here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a possibility for later optimization. It is a non-trivial task to keep a table state in memory and keep it sync with the actual table - especially when there are independent writers to the table
...ink/src/main/java/org/apache/iceberg/flink/maintenance/operator/DataFileRewriteExecutor.java
Show resolved
Hide resolved
...ink/src/main/java/org/apache/iceberg/flink/maintenance/operator/DataFileRewriteExecutor.java
Show resolved
Hide resolved
...nk/src/main/java/org/apache/iceberg/flink/maintenance/operator/DataFileRewriteCommitter.java
Outdated
Show resolved
Hide resolved
...nk/src/main/java/org/apache/iceberg/flink/maintenance/operator/DataFileRewriteCommitter.java
Outdated
Show resolved
Hide resolved
...nk/src/main/java/org/apache/iceberg/flink/maintenance/operator/DataFileRewriteCommitter.java
Outdated
Show resolved
Hide resolved
|
To summarise the state, I see the following open questions:
State handling and restoration
Currently the following ideas emerged to handle the situation:
How to handle table schema, specification, configuration changes
How to handle errors
Another ortogonal question wrt. the exceptions is what to propagate:
My current preferences:
|
|
Rebased based on the new API. Thanks, |
flink/v1.20/flink/src/main/java/org/apache/iceberg/flink/maintenance/api/RewriteDataFiles.java
Outdated
Show resolved
Hide resolved
flink/v1.20/flink/src/main/java/org/apache/iceberg/flink/maintenance/api/RewriteDataFiles.java
Outdated
Show resolved
Hide resolved
flink/v1.20/flink/src/main/java/org/apache/iceberg/flink/maintenance/api/RewriteDataFiles.java
Outdated
Show resolved
Hide resolved
flink/v1.20/flink/src/main/java/org/apache/iceberg/flink/maintenance/api/TableMaintenance.java
Outdated
Show resolved
Hide resolved
...link/src/main/java/org/apache/iceberg/flink/maintenance/operator/DataFileRewritePlanner.java
Outdated
Show resolved
Hide resolved
...v1.20/flink/src/test/java/org/apache/iceberg/flink/maintenance/api/TestRewriteDataFiles.java
Show resolved
Hide resolved
...v1.20/flink/src/test/java/org/apache/iceberg/flink/maintenance/api/TestRewriteDataFiles.java
Show resolved
Hide resolved
...v1.20/flink/src/test/java/org/apache/iceberg/flink/maintenance/api/TestRewriteDataFiles.java
Show resolved
Hide resolved
...v1.20/flink/src/test/java/org/apache/iceberg/flink/maintenance/api/TestRewriteDataFiles.java
Outdated
Show resolved
Hide resolved
...1.20/flink/src/test/java/org/apache/iceberg/flink/maintenance/operator/OperatorTestBase.java
Show resolved
Hide resolved
flink/v1.20/flink/src/main/java/org/apache/iceberg/flink/maintenance/api/ExpireSnapshots.java
Show resolved
Hide resolved
...rc/test/java/org/apache/iceberg/flink/maintenance/operator/TestDataFileRewriteCommitter.java
Outdated
Show resolved
Hide resolved
...rc/test/java/org/apache/iceberg/flink/maintenance/operator/TestDataFileRewriteCommitter.java
Show resolved
Hide resolved
...rc/test/java/org/apache/iceberg/flink/maintenance/operator/TestDataFileRewriteCommitter.java
Outdated
Show resolved
Hide resolved
...rc/test/java/org/apache/iceberg/flink/maintenance/operator/TestDataFileRewriteCommitter.java
Outdated
Show resolved
Hide resolved
.../src/test/java/org/apache/iceberg/flink/maintenance/operator/TestDataFileRewritePlanner.java
Outdated
Show resolved
Hide resolved
...k/src/test/java/org/apache/iceberg/flink/maintenance/operator/TestDataFileRewriteRunner.java
Outdated
Show resolved
Hide resolved
...k/src/test/java/org/apache/iceberg/flink/maintenance/operator/TestDataFileRewriteRunner.java
Outdated
Show resolved
Hide resolved
...k/src/test/java/org/apache/iceberg/flink/maintenance/operator/TestDataFileRewriteRunner.java
Show resolved
Hide resolved
...k/src/test/java/org/apache/iceberg/flink/maintenance/operator/TestDataFileRewriteRunner.java
Show resolved
Hide resolved
|
@stevenzwu: Thanks for the review! Thanks, Peter |
Guosmilesmile
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some small confuse
.../flink/src/main/java/org/apache/iceberg/flink/maintenance/operator/TaskResultAggregator.java
Outdated
Show resolved
Hide resolved
...flink/src/main/java/org/apache/iceberg/flink/maintenance/operator/DataFileRewriteRunner.java
Outdated
Show resolved
Hide resolved
...rc/test/java/org/apache/iceberg/flink/maintenance/operator/TestDataFileRewriteCommitter.java
Show resolved
Hide resolved
...rc/test/java/org/apache/iceberg/flink/maintenance/operator/TestDataFileRewriteCommitter.java
Outdated
Show resolved
Hide resolved
...rc/test/java/org/apache/iceberg/flink/maintenance/operator/TestDataFileRewriteCommitter.java
Outdated
Show resolved
Hide resolved
.../src/test/java/org/apache/iceberg/flink/maintenance/operator/TestDataFileRewritePlanner.java
Outdated
Show resolved
Hide resolved
.../src/test/java/org/apache/iceberg/flink/maintenance/operator/TestDataFileRewritePlanner.java
Outdated
Show resolved
Hide resolved
...k/src/test/java/org/apache/iceberg/flink/maintenance/operator/TestDataFileRewriteRunner.java
Show resolved
Hide resolved
|
Merged to main. |
Compaction implementation.
For details see:
https://docs.google.com/document/d/16g3vR18mVBy8jbFaLjf2JwAANuYOmIwr15yDDxovdnA/edit#heading=h.yd2vbtnf7z6w