PDGGK commented on code in PR #19778:
URL: https://github.com/apache/hudi/pull/19778#discussion_r4110743294


##########
hudi-client/hudi-spark-client/src/main/java/org/apache/hudi/client/SparkRDDWriteClient.java:
##########
@@ -80,9 +80,22 @@ public SparkRDDWriteClient(HoodieEngineContext context, 
HoodieWriteConfig client
   public SparkRDDWriteClient(HoodieEngineContext context, HoodieWriteConfig 
writeConfig,
                              Option<EmbeddedTimelineService> timelineService) {
     super(context, writeConfig, timelineService, 
SparkUpgradeDowngradeHelper.getInstance());
-    DistributedRegistryUtil.createWrapperFileSystemRegistries(context, 
writeConfig);
-    this.tableServiceClient = new SparkRDDTableServiceClient<T>(context, 
writeConfig, getTimelineServer());
-    checkSpeculativeExecution();
+    try {
+      DistributedRegistryUtil.createWrapperFileSystemRegistries(context, 
writeConfig);
+      this.tableServiceClient = new SparkRDDTableServiceClient<T>(context, 
writeConfig, getTimelineServer());
+      // The speculative-execution guardrail throws from here, after the base 
client is fully built.
+      checkSpeculativeExecution();
+    } catch (RuntimeException | Error e) {
+      if (this.tableServiceClient != null) {
+        try {
+          this.tableServiceClient.close();
+        } catch (Exception closeFailure) {
+          e.addSuppressed(closeFailure);
+        }
+      }
+      releaseAfterFailedInit(e);

Review Comment:
   Good catch, fixed in dee61ec. The two-argument `releaseAfterFailedInit` is 
now `protected final`, and this path passes `getIndex()`, so the index is 
closed here too, the same as in `close()`. 
`testIndexIsClosedWhenSpeculativeExecutionGuardrailFails` enables 
`spark.speculation` with a mock index and checks that `close()` is called. It 
fails with the old one-argument call.
   



-- 
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]

Reply via email to