You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hudi.apache.org by GitBox <gi...@apache.org> on 2020/04/07 05:05:13 UTC

[GitHub] [incubator-hudi] vinothchandar opened a new pull request #1492: [WIP] [HUDI-761] Refactoring rollback and restore actions using the ActionExecutor abstraction

vinothchandar opened a new pull request #1492: [WIP] [HUDI-761] Refactoring rollback and restore actions using the ActionExecutor abstraction
URL: https://github.com/apache/incubator-hudi/pull/1492
 
 
   …xecutor abstraction
   
   ## *Tips*
   - *Thank you very much for contributing to Apache Hudi.*
   - *Please review https://hudi.apache.org/contributing.html before opening a pull request.*
   
   ## What is the purpose of the pull request
   
   *(For example: This pull request adds quick-start document.)*
   
   ## Brief change log
   
   *(for example:)*
     - *Modify AnnotationLocation checkstyle rule in checkstyle.xml*
   
   ## Verify this pull request
   
   *(Please pick either of the following options)*
   
   This pull request is a trivial rework / code cleanup without any test coverage.
   
   *(or)*
   
   This pull request is already covered by existing tests, such as *(please describe tests)*.
   
   (or)
   
   This change added tests and can be verified as follows:
   
   *(example:)*
   
     - *Added integration tests for end-to-end.*
     - *Added HoodieClientWriteTest to verify the change.*
     - *Manually verified the change by running a job locally.*
   
   ## Committer checklist
   
    - [ ] Has a corresponding JIRA in PR title & commit
    
    - [ ] Commit message is descriptive of the change
    
    - [ ] CI is green
   
    - [ ] Necessary doc changes done or have another open PR
          
    - [ ] For large changes, please consider breaking it into sub-tasks under an umbrella JIRA.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-hudi] codecov-io commented on issue #1492: [WIP] [HUDI-761] Refactoring rollback and restore actions using the ActionExecutor abstraction

Posted by GitBox <gi...@apache.org>.
codecov-io commented on issue #1492: [WIP] [HUDI-761] Refactoring rollback and restore actions using the ActionExecutor abstraction
URL: https://github.com/apache/incubator-hudi/pull/1492#issuecomment-612535235
 
 
   # [Codecov](https://codecov.io/gh/apache/incubator-hudi/pull/1492?src=pr&el=h1) Report
   > Merging [#1492](https://codecov.io/gh/apache/incubator-hudi/pull/1492?src=pr&el=desc) into [master](https://codecov.io/gh/apache/incubator-hudi/commit/a464a2972e83e648585277ebe567703c8285cf1e&el=desc) will **increase** coverage by `0.03%`.
   > The diff coverage is `79.69%`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/incubator-hudi/pull/1492/graphs/tree.svg?width=650&height=150&src=pr&token=VTTXabwbs2)](https://codecov.io/gh/apache/incubator-hudi/pull/1492?src=pr&el=tree)
   
   ```diff
   @@             Coverage Diff              @@
   ##             master    #1492      +/-   ##
   ============================================
   + Coverage     72.20%   72.23%   +0.03%     
     Complexity      289      289              
   ============================================
     Files           338      345       +7     
     Lines         15946    15987      +41     
     Branches       1624     1629       +5     
   ============================================
   + Hits          11514    11549      +35     
   - Misses         3704     3708       +4     
   - Partials        728      730       +2     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/incubator-hudi/pull/1492?src=pr&el=tree) | Coverage Δ | Complexity Δ | |
   |---|---|---|---|
   | [.../apache/hudi/client/AbstractHoodieWriteClient.java](https://codecov.io/gh/apache/incubator-hudi/pull/1492/diff?src=pr&el=tree#diff-aHVkaS1jbGllbnQvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2h1ZGkvY2xpZW50L0Fic3RyYWN0SG9vZGllV3JpdGVDbGllbnQuamF2YQ==) | `77.77% <ø> (+3.62%)` | `0.00 <0.00> (ø)` | |
   | [.../apache/hudi/exception/HoodieRestoreException.java](https://codecov.io/gh/apache/incubator-hudi/pull/1492/diff?src=pr&el=tree#diff-aHVkaS1jbGllbnQvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2h1ZGkvZXhjZXB0aW9uL0hvb2RpZVJlc3RvcmVFeGNlcHRpb24uamF2YQ==) | `0.00% <0.00%> (ø)` | `0.00 <0.00> (?)` | |
   | [...c/main/java/org/apache/hudi/table/HoodieTable.java](https://codecov.io/gh/apache/incubator-hudi/pull/1492/diff?src=pr&el=tree#diff-aHVkaS1jbGllbnQvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2h1ZGkvdGFibGUvSG9vZGllVGFibGUuamF2YQ==) | `79.64% <ø> (ø)` | `0.00 <0.00> (ø)` | |
   | [...g/apache/hudi/table/action/BaseActionExecutor.java](https://codecov.io/gh/apache/incubator-hudi/pull/1492/diff?src=pr&el=tree#diff-aHVkaS1jbGllbnQvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2h1ZGkvdGFibGUvYWN0aW9uL0Jhc2VBY3Rpb25FeGVjdXRvci5qYXZh) | `100.00% <ø> (ø)` | `0.00 <0.00> (ø)` | |
   | [...che/hudi/table/action/rollback/RollbackHelper.java](https://codecov.io/gh/apache/incubator-hudi/pull/1492/diff?src=pr&el=tree#diff-aHVkaS1jbGllbnQvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2h1ZGkvdGFibGUvYWN0aW9uL3JvbGxiYWNrL1JvbGxiYWNrSGVscGVyLmphdmE=) | `80.43% <ø> (ø)` | `0.00 <0.00> (?)` | |
   | [...he/hudi/table/action/rollback/RollbackRequest.java](https://codecov.io/gh/apache/incubator-hudi/pull/1492/diff?src=pr&el=tree#diff-aHVkaS1jbGllbnQvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2h1ZGkvdGFibGUvYWN0aW9uL3JvbGxiYWNrL1JvbGxiYWNrUmVxdWVzdC5qYXZh) | `94.73% <ø> (ø)` | `0.00 <0.00> (?)` | |
   | [...java/org/apache/hudi/client/HoodieWriteClient.java](https://codecov.io/gh/apache/incubator-hudi/pull/1492/diff?src=pr&el=tree#diff-aHVkaS1jbGllbnQvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2h1ZGkvY2xpZW50L0hvb2RpZVdyaXRlQ2xpZW50LmphdmE=) | `66.58% <55.88%> (-2.65%)` | `0.00 <0.00> (ø)` | |
   | [...tion/restore/CopyOnWriteRestoreActionExecutor.java](https://codecov.io/gh/apache/incubator-hudi/pull/1492/diff?src=pr&el=tree#diff-aHVkaS1jbGllbnQvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2h1ZGkvdGFibGUvYWN0aW9uL3Jlc3RvcmUvQ29weU9uV3JpdGVSZXN0b3JlQWN0aW9uRXhlY3V0b3IuamF2YQ==) | `75.00% <75.00%> (ø)` | `0.00 <0.00> (?)` | |
   | [...tion/restore/MergeOnReadRestoreActionExecutor.java](https://codecov.io/gh/apache/incubator-hudi/pull/1492/diff?src=pr&el=tree#diff-aHVkaS1jbGllbnQvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2h1ZGkvdGFibGUvYWN0aW9uL3Jlc3RvcmUvTWVyZ2VPblJlYWRSZXN0b3JlQWN0aW9uRXhlY3V0b3IuamF2YQ==) | `75.00% <75.00%> (ø)` | `0.00 <0.00> (?)` | |
   | [...le/action/rollback/BaseRollbackActionExecutor.java](https://codecov.io/gh/apache/incubator-hudi/pull/1492/diff?src=pr&el=tree#diff-aHVkaS1jbGllbnQvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2h1ZGkvdGFibGUvYWN0aW9uL3JvbGxiYWNrL0Jhc2VSb2xsYmFja0FjdGlvbkV4ZWN1dG9yLmphdmE=) | `77.77% <77.77%> (ø)` | `0.00 <0.00> (?)` | |
   | ... and [18 more](https://codecov.io/gh/apache/incubator-hudi/pull/1492/diff?src=pr&el=tree-more) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/incubator-hudi/pull/1492?src=pr&el=continue).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/incubator-hudi/pull/1492?src=pr&el=footer). Last update [a464a29...6e48a53](https://codecov.io/gh/apache/incubator-hudi/pull/1492?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-hudi] vinothchandar merged pull request #1492: [HUDI-761] Refactoring rollback and restore actions using the ActionExecutor abstraction

Posted by GitBox <gi...@apache.org>.
vinothchandar merged pull request #1492: [HUDI-761] Refactoring rollback and restore actions using the ActionExecutor abstraction
URL: https://github.com/apache/incubator-hudi/pull/1492
 
 
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-hudi] vinothchandar commented on issue #1492: [HUDI-761] Refactoring rollback and restore actions using the ActionExecutor abstraction

Posted by GitBox <gi...@apache.org>.
vinothchandar commented on issue #1492: [HUDI-761] Refactoring rollback and restore actions using the ActionExecutor abstraction
URL: https://github.com/apache/incubator-hudi/pull/1492#issuecomment-612778656
 
 
   Rebased again.. Will wait for CI to pass and merge. 

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-hudi] vinothchandar commented on issue #1492: [WIP] [HUDI-761] Refactoring rollback and restore actions using the ActionExecutor abstraction

Posted by GitBox <gi...@apache.org>.
vinothchandar commented on issue #1492: [WIP] [HUDI-761] Refactoring rollback and restore actions using the ActionExecutor abstraction
URL: https://github.com/apache/incubator-hudi/pull/1492#issuecomment-610175780
 
 
   still have a case to fix.. but provide sufficient ideas for you.. @bvaradar 

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-hudi] vinothchandar commented on a change in pull request #1492: [HUDI-761] Refactoring rollback and restore actions using the ActionExecutor abstraction

Posted by GitBox <gi...@apache.org>.
vinothchandar commented on a change in pull request #1492: [HUDI-761] Refactoring rollback and restore actions using the ActionExecutor abstraction
URL: https://github.com/apache/incubator-hudi/pull/1492#discussion_r407346793
 
 

 ##########
 File path: hudi-client/src/main/java/org/apache/hudi/table/action/rollback/CopyOnWriteRollbackActionExecutor.java
 ##########
 @@ -0,0 +1,94 @@
+/*
+ * 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.hudi.table.action.rollback;
+
+import org.apache.hudi.common.HoodieRollbackStat;
+import org.apache.hudi.common.fs.FSUtils;
+import org.apache.hudi.common.table.timeline.HoodieActiveTimeline;
+import org.apache.hudi.common.table.timeline.HoodieInstant;
+import org.apache.hudi.config.HoodieWriteConfig;
+import org.apache.hudi.table.HoodieTable;
+import org.apache.log4j.LogManager;
+import org.apache.log4j.Logger;
+import org.apache.spark.api.java.JavaSparkContext;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
+
+public class CopyOnWriteRollbackActionExecutor extends BaseRollbackActionExecutor {
+
+  private static final Logger LOG = LogManager.getLogger(CopyOnWriteRollbackActionExecutor.class);
+
+  public CopyOnWriteRollbackActionExecutor(JavaSparkContext jsc,
+                                           HoodieWriteConfig config,
+                                           HoodieTable<?> table,
+                                           String instantTime,
+                                           HoodieInstant commitInstant,
+                                           boolean deleteInstants) {
+    super(jsc, config, table, instantTime, commitInstant, deleteInstants);
+  }
+
+  public CopyOnWriteRollbackActionExecutor(JavaSparkContext jsc,
+                                           HoodieWriteConfig config,
+                                           HoodieTable<?> table,
+                                           String instantTime,
+                                           HoodieInstant commitInstant,
+                                           boolean deleteInstants,
+                                           boolean skipTimelinePublish) {
+    super(jsc, config, table, instantTime, commitInstant, deleteInstants, skipTimelinePublish);
+  }
+
+  @Override
+  protected List<HoodieRollbackStat> executeRollback() throws IOException {
+    long startTime = System.currentTimeMillis();
+    List<HoodieRollbackStat> stats = new ArrayList<>();
+    HoodieActiveTimeline activeTimeline = table.getActiveTimeline();
+    HoodieInstant resolvedInstant = instantToRollback;
+
+    if (instantToRollback.isCompleted()) {
+      LOG.info("Unpublishing instant " + instantToRollback);
+      resolvedInstant = activeTimeline.revertToInflight(instantToRollback);
+    }
+
+    // For Requested State (like failure during index lookup), there is nothing to do rollback other than
+    // deleting the timeline file
+    if (!resolvedInstant.isRequested()) {
+      // delete all the data files for this commit
+      LOG.info("Clean out all parquet files generated for commit: " + resolvedInstant);
+      List<RollbackRequest> rollbackRequests = generateRollbackRequests(resolvedInstant);
+
+      //TODO: We need to persist this as rollback workload and use it in case of partial failures
+      stats = new RollbackHelper(table.getMetaClient(), config).performRollback(jsc, resolvedInstant, rollbackRequests);
+    }
+    // Delete Inflight instant if enabled
+    deleteInflightAndRequestedInstant(deleteInstants, activeTimeline, resolvedInstant);
+    LOG.info("Time(in ms) taken to finish rollback " + (System.currentTimeMillis() - startTime));
+    return stats;
+  }
+
+  private List<RollbackRequest> generateRollbackRequests(HoodieInstant instantToRollback)
+      throws IOException {
+    return FSUtils.getAllPartitionPaths(table.getMetaClient().getFs(), table.getMetaClient().getBasePath(),
+        config.shouldAssumeDatePartitioning()).stream()
+        .map(partitionPath -> RollbackRequest.createRollbackRequestWithDeleteDataAndLogFilesAction(partitionPath, instantToRollback))
 
 Review comment:
   it is.. https://github.com/apache/incubator-hudi/blob/master/hudi-client/src/main/java/org/apache/hudi/table/HoodieCopyOnWriteTable.java#L237 does call this.. and this is the commit that introduce this.. https://github.com/apache/incubator-hudi/pull/968/files#diff-47ab1d64d6b64228b07d3c4c4559786cR328
   
   def worth following up 

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-hudi] bvaradar commented on a change in pull request #1492: [HUDI-761] Refactoring rollback and restore actions using the ActionExecutor abstraction

Posted by GitBox <gi...@apache.org>.
bvaradar commented on a change in pull request #1492: [HUDI-761] Refactoring rollback and restore actions using the ActionExecutor abstraction
URL: https://github.com/apache/incubator-hudi/pull/1492#discussion_r407342052
 
 

 ##########
 File path: hudi-client/src/main/java/org/apache/hudi/table/action/rollback/CopyOnWriteRollbackActionExecutor.java
 ##########
 @@ -0,0 +1,94 @@
+/*
+ * 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.hudi.table.action.rollback;
+
+import org.apache.hudi.common.HoodieRollbackStat;
+import org.apache.hudi.common.fs.FSUtils;
+import org.apache.hudi.common.table.timeline.HoodieActiveTimeline;
+import org.apache.hudi.common.table.timeline.HoodieInstant;
+import org.apache.hudi.config.HoodieWriteConfig;
+import org.apache.hudi.table.HoodieTable;
+import org.apache.log4j.LogManager;
+import org.apache.log4j.Logger;
+import org.apache.spark.api.java.JavaSparkContext;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
+
+public class CopyOnWriteRollbackActionExecutor extends BaseRollbackActionExecutor {
+
+  private static final Logger LOG = LogManager.getLogger(CopyOnWriteRollbackActionExecutor.class);
+
+  public CopyOnWriteRollbackActionExecutor(JavaSparkContext jsc,
+                                           HoodieWriteConfig config,
+                                           HoodieTable<?> table,
+                                           String instantTime,
+                                           HoodieInstant commitInstant,
+                                           boolean deleteInstants) {
+    super(jsc, config, table, instantTime, commitInstant, deleteInstants);
+  }
+
+  public CopyOnWriteRollbackActionExecutor(JavaSparkContext jsc,
+                                           HoodieWriteConfig config,
+                                           HoodieTable<?> table,
+                                           String instantTime,
+                                           HoodieInstant commitInstant,
+                                           boolean deleteInstants,
+                                           boolean skipTimelinePublish) {
+    super(jsc, config, table, instantTime, commitInstant, deleteInstants, skipTimelinePublish);
+  }
+
+  @Override
+  protected List<HoodieRollbackStat> executeRollback() throws IOException {
+    long startTime = System.currentTimeMillis();
+    List<HoodieRollbackStat> stats = new ArrayList<>();
+    HoodieActiveTimeline activeTimeline = table.getActiveTimeline();
+    HoodieInstant resolvedInstant = instantToRollback;
+
+    if (instantToRollback.isCompleted()) {
+      LOG.info("Unpublishing instant " + instantToRollback);
+      resolvedInstant = activeTimeline.revertToInflight(instantToRollback);
+    }
+
+    // For Requested State (like failure during index lookup), there is nothing to do rollback other than
+    // deleting the timeline file
+    if (!resolvedInstant.isRequested()) {
+      // delete all the data files for this commit
+      LOG.info("Clean out all parquet files generated for commit: " + resolvedInstant);
+      List<RollbackRequest> rollbackRequests = generateRollbackRequests(resolvedInstant);
+
+      //TODO: We need to persist this as rollback workload and use it in case of partial failures
+      stats = new RollbackHelper(table.getMetaClient(), config).performRollback(jsc, resolvedInstant, rollbackRequests);
+    }
+    // Delete Inflight instant if enabled
+    deleteInflightAndRequestedInstant(deleteInstants, activeTimeline, resolvedInstant);
+    LOG.info("Time(in ms) taken to finish rollback " + (System.currentTimeMillis() - startTime));
+    return stats;
+  }
+
+  private List<RollbackRequest> generateRollbackRequests(HoodieInstant instantToRollback)
+      throws IOException {
+    return FSUtils.getAllPartitionPaths(table.getMetaClient().getFs(), table.getMetaClient().getBasePath(),
+        config.shouldAssumeDatePartitioning()).stream()
+        .map(partitionPath -> RollbackRequest.createRollbackRequestWithDeleteDataAndLogFilesAction(partitionPath, instantToRollback))
 
 Review comment:
   This is not related to current change. Wondering why COW rollback needs to deal with  log files rollback. Should not be a correctness issue but would warrant a fix. I can open a jira and look at this later if you also think this is weird.  

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-hudi] vinothchandar commented on issue #1492: [HUDI-761] Refactoring rollback and restore actions using the ActionExecutor abstraction

Posted by GitBox <gi...@apache.org>.
vinothchandar commented on issue #1492: [HUDI-761] Refactoring rollback and restore actions using the ActionExecutor abstraction
URL: https://github.com/apache/incubator-hudi/pull/1492#issuecomment-612536463
 
 
   @bvaradar @n3nash please review this bit closely, since this code is fairly high touch.. 

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services