Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PLUGIN-1856] Error management for Wrangler plugin #726

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from

Conversation

Amit-CloudSufi
Copy link

@Amit-CloudSufi Amit-CloudSufi commented Jan 29, 2025

https://cdap.atlassian.net/browse/PLUGIN-1856

image

[
  {
    "stageName": "Wrangler",
    "errorCategory": "Plugin-'Wrangler'",
    "errorReason": "Error in stage 'Wrangler'. Format of output schema specified is invalid. Please check the format. com.google.gson.stream.MalformedJsonException: Unterminated object at line 3 column 4 path $.type",
    "errorMessage": "Error in stage 'Wrangler'. Format of output schema specified is invalid. Please check the format. com.google.gson.stream.MalformedJsonException: Unterminated object at line 3 column 4 path $.type",
    "errorType": "USER",
    "dependency": "false"
  }
]
2025-01-30 12:36:48,237 - ERROR [spark-submitter-phase-1-bfc7d018-ded8-11ef-8496-0000009adf90:o.a.s.i.i.SparkHadoopWriter@98] - Aborting job job_202501301236463168859500037448187_0005.
org.apache.spark.SparkException: Job aborted due to stage failure: Task 0 in stage 0.0 failed 1 times, most recent failure: Lost task 0.0 in stage 0.0 (TID 0) (192.168.1.100 executor driver): org.apache.spark.SparkException: Task failed while writing rows
	at org.apache.spark.internal.io.SparkHadoopWriter$.executeTask(SparkHadoopWriter.scala:163)
	at org.apache.spark.internal.io.SparkHadoopWriter$.$anonfun$write$1(SparkHadoopWriter.scala:88)
	at org.apache.spark.scheduler.ResultTask.runTask(ResultTask.scala:90)
	at org.apache.spark.scheduler.Task.run(Task.scala:136)
	at org.apache.spark.executor.Executor$TaskRunner.$anonfun$run$3(Executor.scala:548)
	at org.apache.spark.util.Utils$.tryWithSafeFinally(Utils.scala:1504)
	at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:551)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:750)
Caused by: java.util.concurrent.ExecutionException: Error when transforming stage Wrangler: com.google.common.util.concurrent.UncheckedExecutionException: io.cdap.cdap.api.exception.WrappedStageException: Stage 'Wrangler' encountered : io.cdap.cdap.api.exception.ProgramFailureException: Error in stage 'Wrangler'. Format of output schema specified is invalid. Please check the format. com.google.gson.stream.MalformedJsonException: Unterminated object at line 3 column 4 path $.type
	at io.cdap.cdap.etl.spark.function.TransformFunction.call(TransformFunction.java:61)
	at org.apache.spark.api.java.JavaRDDLike.$anonfun$flatMap$1(JavaRDDLike.scala:125)
	at scala.collection.Iterator$$anon$11.nextCur(Iterator.scala:486)
	at scala.collection.Iterator$$anon$11.hasNext(Iterator.scala:492)
	at scala.collection.Iterator$$anon$11.hasNext(Iterator.scala:491)
	at scala.collection.Iterator$$anon$11.hasNext(Iterator.scala:491)
	at org.apache.spark.internal.io.SparkHadoopWriter$.$anonfun$executeTask$1(SparkHadoopWriter.scala:136)
	at org.apache.spark.util.Utils$.tryWithSafeFinallyAndFailureCallbacks(Utils.scala:1538)
	at org.apache.spark.internal.io.SparkHadoopWriter$.executeTask(SparkHadoopWriter.scala:135)
	... 9 more
Loading Directive exception:

image
image

@Amit-CloudSufi Amit-CloudSufi force-pushed the wranglerTransformPlugin branch from df84fa4 to b70d696 Compare January 29, 2025 08:25
@Amit-CloudSufi Amit-CloudSufi changed the title Error management for Wrangler plugin [PLUGIN-1856] Error management for Wrangler plugin Jan 29, 2025
@Amit-CloudSufi Amit-CloudSufi force-pushed the wranglerTransformPlugin branch from f48259e to 97fa44c Compare January 29, 2025 08:41
@Amit-CloudSufi Amit-CloudSufi force-pushed the wranglerTransformPlugin branch from a54195a to d46f401 Compare January 29, 2025 08:57
@Amit-CloudSufi Amit-CloudSufi force-pushed the wranglerTransformPlugin branch from 335bb68 to 1e04c2d Compare January 29, 2025 09:13
@Amit-CloudSufi Amit-CloudSufi force-pushed the wranglerTransformPlugin branch 2 times, most recently from be7d0f8 to 645593d Compare January 29, 2025 09:35
@psainics psainics added the build Triggers unit test build label Jan 29, 2025
String errorMessage = String.format("Precondition '%s' does not result in true or false.",
condition);
throw WranglerUtil.getProgramFailureExceptionDetailsFromChain(null, errorMessage,
ErrorType.USER, false);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why user ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think, user entered the wrong precondition, let me know if you think it can be system error?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not handle it at WranglerErrorUtil level?

For all DirectiveParseException, DirectiveLoadException, RecipeException & PreconditionException error type can be USER.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At few places, we have System error , that's why have made this method generic. If we put null at error type, by default it will be set to USER in WranglerErrorUtil class.

Copy link
Contributor

@psainics psainics left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please Fix Unit Tests

@psainics
Copy link
Contributor

E2E Fixed in #727 !

@@ -34,7 +35,7 @@ public void testPrecondition() throws Exception {
Assert.assertEquals(false, new Precondition("false").apply(row));
}

@Test(expected = PreconditionException.class)
@Test(expected = ProgramFailureException.class)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please match error message to verify we are catching the correct error !

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done matched

Copy link
Member

@itsankit-google itsankit-google Jan 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are still not matching errorMessage, only matching Exception class, this comment is still not resolved.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The above expected = ProgramFailureException is not needed if you are already catching exception in the test.

String.format("Stage:%s - Format of output schema specified is invalid. Please check the format.",
context.getStageName()), e
);
String errorMessage = String.format("Error in stage '%s'. Format of output schema specified "
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please don't use Error in stage anywhere.

stageName is already present in errorCategory.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

/**
* Util file to handle exceptions caught in Wrangler plugin
*/
public class WranglerUtil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make this class final.

rename it to WranglerErrorUtil

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

"Error in stage '%s'. Please check the configuration or input data. %s: %s",
context.getStageName(), e.getClass().getName(), e.getMessage());
throw WranglerUtil.getProgramFailureExceptionDetailsFromChain(e, errorMessage,
ErrorType.SYSTEM, false);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why system error?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

Comment on lines 47 to 61
if (t instanceof DirectiveLoadException || t instanceof DirectiveParseException
|| t instanceof RecipeException || t instanceof PreconditionException) {
return getProgramFailureException((Exception) t,
errorType != null ? errorType : ErrorType.USER, false);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

based on exception, there can be different subCategory like Parsing-Directive, Loading-Directive, Executing-Recipe & Precondition

@@ -276,8 +286,11 @@ && checkPreconditionNotEmpty(false)) {
}

} catch (Exception e) {
LOG.error(e.getMessage());
collector.addFailure("Error occurred : " + e.getMessage(), null).withStacktrace(e.getStackTrace());
LOG.error("Error occurred during configuration of the plugin, {}: {}", e.getClass().getName(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

be specific in error message what configuration are we referring to here?

Copy link
Member

@itsankit-google itsankit-google left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lots of basic issues in the PR. PTAL, thanks!

@Amit-CloudSufi Amit-CloudSufi force-pushed the wranglerTransformPlugin branch 2 times, most recently from f69a84e to 8231144 Compare January 31, 2025 11:17
Copy link
Member

@itsankit-google itsankit-google left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add evidences/screenshots of all four known exceptions being captured properly in ErrorManagement UI.

Parsing-Directive, Loading-Directive, Executing-Recipe & Precondition

@Amit-CloudSufi Amit-CloudSufi force-pushed the wranglerTransformPlugin branch from 877c7c6 to 32f25df Compare January 31, 2025 12:09
collector.addFailure("Error occurred : " + e.getMessage(), null).withStacktrace(e.getStackTrace());
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: remove empty line

Comment on lines 63 to 78
if (t instanceof DirectiveLoadException) {
return getProgramFailureException((DirectiveLoadException) t,
errorType != null ? errorType : ErrorType.USER, false, "Loading-Directive");
}
if (t instanceof DirectiveParseException) {
return getProgramFailureException((DirectiveParseException) t,
errorType != null ? errorType : ErrorType.USER, false, "Parsing-Directive");
}
if (t instanceof RecipeException) {
return getProgramFailureException((RecipeException) t,
errorType != null ? errorType : ErrorType.USER, false, "Executing-Recipe");
}
if (t instanceof PreconditionException) {
return getProgramFailureException((PreconditionException) t,
errorType != null ? errorType : ErrorType.USER, false, "Precondition");
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are few more known exceptions like DirectiveNotFoundException, DirectiveExecutionException

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build Triggers unit test build
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants