amogh-jahagirdar commented on code in PR #14341:
URL: https://github.com/apache/iceberg/pull/14341#discussion_r2441358729


##########
api/src/main/java/org/apache/iceberg/actions/RepairManifests.java:
##########
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.iceberg.actions;
+
+import org.apache.iceberg.ManifestFile;
+
+/** An action that will repair manifests. Implementations should produce a new 
set of manifests. */
+public interface RepairManifests extends SnapshotUpdate<RepairManifests, 
RepairManifests.Result> {
+
+  /**
+   * Configuration method for repairing manifest entry statistics
+   *
+   * @return this for method chaining
+   */
+  RepairManifests repairEntryStats();
+
+  /**
+   * Configuration method for removing duplicate file entries and removing 
files which no longer
+   * exist in storage
+   *
+   * @return this for method chaining
+   */
+  RepairManifests repairFileEntries();
+
+  /**
+   * Configuration option to preview repair manifest operation without 
actually committing the
+   * operation to the table
+   *
+   * @return this for method chaining
+   */
+  RepairManifests dryRun();
+
+  /** The action result that contains a summary of the execution. */
+  interface Result {
+    /** Returns rewritten manifests. */
+    Iterable<ManifestFile> rewrittenManifests();
+
+    /** Returns the number of duplicate file entries that were removed from 
manifests */
+    long duplicateFilesRemoved();
+
+    /** Returns the number of missing file references that were removed from 
manifests */
+    long missingFilesRemoved();
+
+    /** Returns the number of missing files that were successfully recovered. 
*/
+    long missingFilesRecovered();
+
+    /** Returns the number of manifest entries for which stats were incorrect 
*/
+    long entryStatsIncorrectCount();
+
+    /** Returns the number of manifest entries for which stats were corrected 
*/
+    long entryStatsRepairedCount();

Review Comment:
   Hm, when would these two not be the same? If it's incorrect, we'd always 
correct it no? 



##########
api/src/main/java/org/apache/iceberg/actions/RepairManifests.java:
##########
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.iceberg.actions;
+
+import org.apache.iceberg.ManifestFile;
+
+/** An action that will repair manifests. Implementations should produce a new 
set of manifests. */
+public interface RepairManifests extends SnapshotUpdate<RepairManifests, 
RepairManifests.Result> {
+
+  /**
+   * Configuration method for repairing manifest entry statistics
+   *
+   * @return this for method chaining
+   */
+  RepairManifests repairEntryStats();
+
+  /**
+   * Configuration method for removing duplicate file entries and removing 
files which no longer
+   * exist in storage

Review Comment:
   Yeah fundamentally the goal of this repair procedure is for unblocking users 
to access their tables. 
   
   When there are files referenced in metadata that don't actually exist in 
storage (caused by object storage retention policies typically), then there's a 
choice:
   
   1. Either the file can be recovered. If it can be, I think we should always 
try for that.
   2. The file cannot be recovered, in which case we should unblock the users 
table by removing that file, and indicating to the user that a file was missing 
and could not be recovered, and as a result we removed it. 
   
   We _could_ treat best effort file recovery as separate but I don't really 
see the value in that. If you're running this procedure, you're probably 
running it because you hit some failure and you invoke this procedure with the 
intent to get the table back to a readable state.
   
   They key thing is that the output should indicate what happened to a user so 
they can at least reason about the fact that after this procedure there may be 
more (in case of recovery) records than before. 
   



##########
api/src/main/java/org/apache/iceberg/actions/RepairManifests.java:
##########
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.iceberg.actions;
+
+import org.apache.iceberg.ManifestFile;
+
+/** An action that will repair manifests. Implementations should produce a new 
set of manifests. */
+public interface RepairManifests extends SnapshotUpdate<RepairManifests, 
RepairManifests.Result> {
+
+  /**
+   * Configuration method for repairing manifest entry statistics
+   *
+   * @return this for method chaining
+   */
+  RepairManifests repairEntryStats();
+
+  /**
+   * Configuration method for removing duplicate file entries and removing 
files which no longer
+   * exist in storage
+   *
+   * @return this for method chaining
+   */
+  RepairManifests repairFileEntries();
+
+  /**
+   * Configuration option to preview repair manifest operation without 
actually committing the
+   * operation to the table
+   *
+   * @return this for method chaining
+   */
+  RepairManifests dryRun();
+
+  /** The action result that contains a summary of the execution. */
+  interface Result {
+    /** Returns rewritten manifests. */
+    Iterable<ManifestFile> rewrittenManifests();
+
+    /** Returns the number of duplicate file entries that were removed from 
manifests */
+    long duplicateFilesRemoved();
+
+    /** Returns the number of missing file references that were removed from 
manifests */
+    long missingFilesRemoved();
+
+    /** Returns the number of missing files that were successfully recovered. 
*/
+    long missingFilesRecovered();

Review Comment:
   I think last time most of the debate was on the output, which I think I'd 
like to advance the conversation a bit more. So the way I look at this is as a 
user I really want to see numbers of files that were repaired in the different 
categories.
   
   I don't think we particularly care about the actual paths of data files, and 
besides that result set could be unfortunately large. Even if we do output for 
example which files were removed because they just don't exist and could not be 
recovered, that's not actionable output to a user; that file is just gone. 
   
   The numbers would clearly indicate how many files have been recovered, how 
many files have not been recovered, how many duplicates existed.
   
   Then we could surface the higher level in the tree of which manifests were 
rewritten. If someone really cares about which particular files were there they 
could go through those. and even later on in the API it's not a 1 way door, if 
there's a need to see which particular files  we could have an option to output 
those files to some other file.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to