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


##########
hudi-utilities/src/main/java/org/apache/hudi/utilities/streamer/validator/SparkWriteErrorValidator.java:
##########
@@ -0,0 +1,136 @@
+/*
+ * 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.utilities.streamer.validator;
+
+import org.apache.hudi.client.validator.BasePreCommitValidator;
+import org.apache.hudi.client.validator.ValidationContext;
+import org.apache.hudi.common.config.TypedProperties;
+import org.apache.hudi.config.HoodiePreCommitValidatorConfig;
+import 
org.apache.hudi.config.HoodiePreCommitValidatorConfig.ValidationFailurePolicy;
+import org.apache.hudi.exception.HoodieValidationException;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Arrays;
+
+/**
+ * Pre-commit validator that fails the commit when records failed to write.
+ *
+ * <p>Equivalent of the legacy {@code HoodieStreamerWriteStatusValidator}'s 
boolean error check
+ * ({@code hasErrorRecords = totalErrorRecords > 0}), wired through the 
pre-commit validator
+ * framework (issue #18750). Pure validation: no side effects (no error-table 
commit, no
+ * top-100 error logging, no instant rollback). Those side effects are handled 
separately by
+ * {@code StreamSync}'s pre-commit orchestration.</p>
+ *
+ * <p><b>Relationship with the inline write-error gate in {@code 
StreamSync}:</b> the default
+ * commit path in {@code StreamSync} already applies an equivalent error check 
via the
+ * {@code commitOnErrors} flag. This validator exists so that users running 
multiple validators
+ * (e.g. write-error + offset checks) can express a unified pass/fail story 
through a single
+ * {@code failure.policy} knob. Enabling this validator while leaving {@code 
commitOnErrors=false}
+ * means both checks run and either can block the commit — they are 
intentionally not mutually
+ * exclusive.</p>
+ *
+ * <p>Behavior mapping from the legacy HSWSV (data-table only — see caveat 
below):</p>
+ * <ul>
+ *   <li>{@code commitOnErrors = false} (HSWSV default) ↔ {@code 
failure.policy = FAIL}</li>
+ *   <li>{@code commitOnErrors = true} ↔ {@code failure.policy = WARN_LOG}</li>
+ * </ul>
+ *
+ * <p><b>Unification caveat:</b> when {@code 
hoodie.errortable.write.unification.enabled=true},
+ * HSWSV's error check summed errors across <em>both</em> the data-table and 
the error-table write

Review Comment:
   I am slightly confused. So, when `failure.policy=WARN_LOG` and 
commitOnErrors is false, then also uiltimately exception will be thrown from 
Step 4 gate correct 
https://github.com/shangxinli/hudi/blob/140e17f9d9d80a7087a949ee10a01e57ee087c52/hudi-utilities/src/main/java/org/apache/hudi/utilities/streamer/StreamSync.java#L953
   
   So, a user who explicitly sets `failure.policy=WARN_LOG` is signaling "I 
want to allow commits despite errors." They'll be confused when the commit is 
still rejected because they didn't also pass --commit-on-errors. It feels like 
the two opt-ins overlap rather when they should compose.



##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/config/HoodiePreCommitValidatorConfig.java:
##########
@@ -46,7 +46,9 @@ public class HoodiePreCommitValidatorConfig extends 
HoodieConfig {
       .withDocumentation("Comma separated list of class names that can be 
invoked to validate commit. "
           + "Available streaming offset validators: "
           + "org.apache.hudi.sink.validator.FlinkKafkaOffsetValidator (Flink 
Kafka), "
-          + 
"org.apache.hudi.utilities.streamer.validator.SparkKafkaOffsetValidator 
(Spark/HoodieStreamer Kafka)");
+          + 
"org.apache.hudi.utilities.streamer.validator.SparkKafkaOffsetValidator 
(Spark/HoodieStreamer Kafka). "
+          + "Available write-error validators: "
+          + 
"org.apache.hudi.utilities.streamer.validator.SparkWriteErrorValidator 
(Spark/HoodieStreamer write errors).");

Review Comment:
   Did we decide on this? I think Step 4 gate is a transitional bridge, 
validator is the future right. We can file a follow-up to register 
`SparkWriteErrorValidator` as a default for HoodieStreamer in next release but 
we will of course need to ensure hot path does not error out because of this.



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