Skip to content

Commit cf014ee

Browse files
SteNicholasyaooqinn
authored andcommitted
[KYUUBI #2078] logCaptureThread does not catch sparksubmit exception
### _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>
1 parent 8e983a1 commit cf014ee

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

kyuubi-server/src/main/scala/org/apache/kyuubi/engine/ProcBuilder.scala

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,14 +148,14 @@ trait ProcBuilder {
148148
val maxErrorSize = conf.get(KyuubiConf.ENGINE_ERROR_MAX_SIZE)
149149
while (true) {
150150
if (reader.ready()) {
151-
var line: String = reader.readLine
152-
if (containsIgnoreCase(line, "Exception:") &&
151+
var line: String = reader.readLine.trim
152+
if (containsException(line) &&
153153
!line.contains("at ") && !line.startsWith("Caused by:")) {
154154
val sb = new StringBuilder(line)
155155
error = KyuubiSQLException(sb.toString() + s"\n See more: $engineLog")
156-
line = reader.readLine()
156+
line = reader.readLine().trim
157157
while (sb.length < maxErrorSize && line != null &&
158-
(containsIgnoreCase(line, "Exception:") ||
158+
(containsException(line) ||
159159
line.startsWith("\tat ") ||
160160
line.startsWith("Caused by: "))) {
161161
sb.append("\n" + line)
@@ -211,6 +211,9 @@ trait ProcBuilder {
211211
case other => other
212212
}
213213
}
214+
215+
private def containsException(log: String): Boolean =
216+
containsIgnoreCase(log, "Exception:") || containsIgnoreCase(log, "Exception in thread")
214217
}
215218

216219
object ProcBuilder extends Logging {

kyuubi-server/src/test/scala/org/apache/kyuubi/engine/spark/SparkProcessBuilderSuite.scala

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,16 @@ class SparkProcessBuilderSuite extends KerberizedTestHelper {
9494
assert(error1.getMessage.contains("See more: "))
9595
assert(!error1.getMessage.contains(msg), "stack trace shall be truncated")
9696
}
97+
98+
val pb3 =
99+
new SparkProcessBuilder("kentyao", conf.set("spark.kerberos.principal", testPrincipal))
100+
pb3.start
101+
eventually(timeout(90.seconds), interval(500.milliseconds)) {
102+
val error1 = pb3.getError
103+
assert(!error1.getMessage.contains("Failed to detect the root cause"))
104+
assert(error1.getMessage.contains("See more: "))
105+
assert(error1.getMessage.contains("Exception in thread"))
106+
}
97107
}
98108

99109
test("proxy user or keytab") {

0 commit comments

Comments
 (0)