zhouyuan commented on code in PR #11676:
URL:
https://github.com/apache/incubator-gluten/pull/11676#discussion_r2888505698
##########
backends-clickhouse/src/main/scala/org/apache/spark/rpc/GlutenExecutorEndpoint.scala:
##########
@@ -100,6 +230,81 @@ class GlutenExecutorEndpoint(val executorId: String, val
conf: SparkConf)
case e =>
logError(s"Received unexpected message. $e")
}
+
+ override def receiveAndReply(context: RpcCallContext): PartialFunction[Any,
Unit] = {
+ case GlutenDumpNativeStackSyncRequest =>
+ try {
+ val pid = ExecutorManager.getProcessId()
+ ensureGdbInstalled()
+ val gdbCmdPrefix = gdbPrefix()
+ val tmpLog = Files.createTempFile("gluten-bt-sync-", ".log")
+ val logPath = tmpLog.toAbsolutePath.toString
+ val charset = StandardCharsets.UTF_8
+ val gdbWithLog = buildGdbWithLogging(gdbCmdPrefix, logPath, pid)
+ logInfo(s"Starting sync native stack collection: pid=$pid,
cmd=$gdbWithLog")
+ val proc = new ProcessBuilder("bash", "-c", gdbWithLog).start()
+ val exitCode = proc.waitFor()
+ val output =
+ try {
+ new String(Files.readAllBytes(tmpLog), charset)
+ } catch { case _: Throwable => "" }
+ try Files.deleteIfExists(tmpLog)
+ catch { case _: Throwable => () }
+ if (exitCode != 0 && (output == null || output.isEmpty)) {
+ context.reply(s"gdb exit code: $exitCode. Please check executor
logs.")
+ } else {
+ context.reply(Option(output).getOrElse(""))
+ }
+ } catch {
+ case t: Throwable =>
+ logWarning("Sync native stack collection failed", t)
+ context.sendFailure(t)
+ }
+ }
+
+ private def has(cmd: String): Boolean = {
+ try {
+ val out = Utils.executeAndGetOutput(
+ Seq("bash", "-c", s"command -v $cmd >/dev/null 2>&1 && echo yes ||
echo no"))
+ out != null && out.trim == "yes"
+ } catch { case _: Throwable => false }
+ }
+
+ private def ensureGdbInstalled(): Unit = {
+ if (!has("gdb")) {
+ val sudo = if (has("sudo")) "sudo " else ""
Review Comment:
In some env it may not allow to install other software
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]