Skip to content

Commit

Permalink
[KYUUBI #2078] logCaptureThread does not catch sparksubmit exception
Browse files Browse the repository at this point in the history
### _Why are the changes needed?_

`logCaptureThread` does not catch sparksubmit exception.

### _How was this patch tested?_
- [ ] Add some test cases that check the changes thoroughly including negative and positive cases if possible

- [ ] Add screenshots for manual tests if appropriate

- [x] [Run test](https://kyuubi.apache.org/docs/latest/develop_tools/testing.html#running-tests) locally before make a pull request

Closes #2090 from SteNicholas/KYUUBI-2078.

Closes #2078

11ff682 [SteNicholas] [KYUUBI #2078] logCaptureThread does not catch sparksubmit exception

Authored-by: SteNicholas <programgeek@163.com>
Signed-off-by: Kent Yao <yao@apache.org>
  • Loading branch information
SteNicholas authored and yaooqinn committed Mar 10, 2022
1 parent 8e983a1 commit cf014ee
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
Expand Up @@ -148,14 +148,14 @@ trait ProcBuilder {
val maxErrorSize = conf.get(KyuubiConf.ENGINE_ERROR_MAX_SIZE)
while (true) {
if (reader.ready()) {
var line: String = reader.readLine
if (containsIgnoreCase(line, "Exception:") &&
var line: String = reader.readLine.trim
if (containsException(line) &&
!line.contains("at ") && !line.startsWith("Caused by:")) {
val sb = new StringBuilder(line)
error = KyuubiSQLException(sb.toString() + s"\n See more: $engineLog")
line = reader.readLine()
line = reader.readLine().trim
while (sb.length < maxErrorSize && line != null &&
(containsIgnoreCase(line, "Exception:") ||
(containsException(line) ||
line.startsWith("\tat ") ||
line.startsWith("Caused by: "))) {
sb.append("\n" + line)
Expand Down Expand Up @@ -211,6 +211,9 @@ trait ProcBuilder {
case other => other
}
}

private def containsException(log: String): Boolean =
containsIgnoreCase(log, "Exception:") || containsIgnoreCase(log, "Exception in thread")
}

object ProcBuilder extends Logging {
Expand Down
Expand Up @@ -94,6 +94,16 @@ class SparkProcessBuilderSuite extends KerberizedTestHelper {
assert(error1.getMessage.contains("See more: "))
assert(!error1.getMessage.contains(msg), "stack trace shall be truncated")
}

val pb3 =
new SparkProcessBuilder("kentyao", conf.set("spark.kerberos.principal", testPrincipal))
pb3.start
eventually(timeout(90.seconds), interval(500.milliseconds)) {
val error1 = pb3.getError
assert(!error1.getMessage.contains("Failed to detect the root cause"))
assert(error1.getMessage.contains("See more: "))
assert(error1.getMessage.contains("Exception in thread"))
}
}

test("proxy user or keytab") {
Expand Down

0 comments on commit cf014ee

Please sign in to comment.