shangxinli commented on code in PR #18765:
URL: https://github.com/apache/hudi/pull/18765#discussion_r3277528998


##########
hudi-utilities/src/main/java/org/apache/hudi/utilities/streamer/StreamSync.java:
##########
@@ -924,9 +924,18 @@ private Pair<Option<String>, JavaRDD<WriteStatus>> 
writeToSinkAndDoMetaSync(Hood
         // Step 2: Run user-configured pre-commit validators (offset, custom, 
and the opt-in
         // SparkWriteErrorValidator). Validators are intentionally stronger 
than commitOnErrors
         // — a failure here aborts the data-table commit regardless of the 
gate in Step 4.
+        // Roll back the inflight data-table instant on validation failure so 
it doesn't leak
+        // under LAZY failed-writes cleanup policy (consistent with Step 1 
ROLLBACK_COMMIT and
+        // the Step 4 gate below). Error-table records already committed in 
Step 1 are preserved
+        // by design — see Step 1's latent-quirk note.
         if (validatorsConfigured) {
-          SparkStreamerValidatorUtils.runValidators(props, instantTime, 
writeStatuses,
-              checkpointCommitMetadata, metaClient);
+          try {
+            SparkStreamerValidatorUtils.runValidators(props, instantTime, 
writeStatuses,
+                checkpointCommitMetadata, metaClient);
+          } catch (HoodieValidationException e) {
+            writeClient.rollback(instantTime);

Review Comment:
   Done in 2406463. Step 2's catch now logs `Pre-commit validators failed for 
instant {instantTime}` (with the validator exception attached for the 
stacktrace), rolls back, and rethrows as 
`HoodieStreamerWriteException("Pre-commit validators failed for instant " + 
instantTime, e)` — matching the rollback+wrap pattern from Step 1 
ROLLBACK_COMMIT and Step 4. Original `HoodieValidationException` preserved as 
the cause.



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