yihua commented on code in PR #5269:
URL: https://github.com/apache/hudi/pull/5269#discussion_r846580321


##########
hudi-client/hudi-spark-client/src/main/java/org/apache/hudi/client/HoodieSparkClusteringClient.java:
##########
@@ -53,11 +53,15 @@ public void cluster(HoodieInstant instant) throws 
IOException {
     SparkRDDWriteClient<T> writeClient = (SparkRDDWriteClient<T>) 
clusteringClient;
     Option<HoodieCommitMetadata> commitMetadata = 
writeClient.cluster(instant.getTimestamp(), true).getCommitMetadata();
     Stream<HoodieWriteStat> hoodieWriteStatStream = 
commitMetadata.get().getPartitionToWriteStats().entrySet().stream().flatMap(e ->
-            e.getValue().stream());
+        e.getValue().stream());
     long errorsCount = 
hoodieWriteStatStream.mapToLong(HoodieWriteStat::getTotalWriteErrors).sum();
     if (errorsCount > 0) {
       // TODO: Should we treat this fatal and throw exception?
       LOG.error("Clustering for instant (" + instant + ") failed with write 
errors");
     }
+    if (writeClient != clusteringClient) {
+      // Clustering write client has been updated with new schema, closing the 
old one
+      writeClient.close();

Review Comment:
   Right.  I've fixed the logic to consider such cases so that the old write 
client is properly closed in all cases.



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