hudi-agent commented on code in PR #19778:
URL: https://github.com/apache/hudi/pull/19778#discussion_r3911253343


##########
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:
   🤖 When this subclass body throws (e.g. checkSpeculativeExecution() with 
spark.speculation=true, or the SparkRDDTableServiceClient ctor), 
releaseAfterFailedInit(e) binds to the base one-arg method, which releases the 
timeline server/heartbeat/txnManager but not this.index that the base 
BaseHoodieWriteClient constructor already created. Both close() and the two-arg 
releaseAfterFailedInit close the index, so this is the one path that skips it. 
Inert today since every HoodieIndex.close() is a no-op, but would leak for any 
index that holds resources. Worth closing the index here too?
   
   <sub><i>⚠️ AI-generated; verify before applying. React 👍/👎 to flag 
quality.</i></sub>



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