Skip to content

Commit bad1e18

Browse files
committed
more log in ccm bridge
1 parent de2e0ff commit bad1e18

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

  • test-infra/src/main/java/com/datastax/oss/driver/api/testinfra/ccm

‎test-infra/src/main/java/com/datastax/oss/driver/api/testinfra/ccm/CcmBridge.java‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,7 @@ public void start() {
299299
} catch (RuntimeException re) {
300300
// if something went wrong starting CCM, see if we can also dump the error
301301
dumpNodeStartupLogs();
302+
dumpProcessTree();
302303
try {
303304
executeCheckLogError();
304305
} catch (RuntimeException checkLogErrorException) {
@@ -349,6 +350,26 @@ private void dumpNodeStartupLogs() {
349350
}
350351
}
351352

353+
/**
354+
* Logs the process tree, to show where a node's launch script is stuck if it never got as far as
355+
* starting the Cassandra JVM (no pid file and empty startup logs).
356+
*/
357+
private void dumpProcessTree() {
358+
try {
359+
Process ps =
360+
new ProcessBuilder("ps", "-eo", "pid,ppid,etime,stat,args", "--forest")
361+
.redirectErrorStream(true)
362+
.start();
363+
String output = new String(ps.getInputStream().readAllBytes(), StandardCharsets.UTF_8);
364+
ps.waitFor(10, TimeUnit.SECONDS);
365+
LOG.error("Process tree:\n{}", output);
366+
} catch (IOException e) {
367+
LOG.error("Failed to dump process tree", e);
368+
} catch (InterruptedException e) {
369+
Thread.currentThread().interrupt();
370+
}
371+
}
372+
352373
public void stop() {
353374
if (started.compareAndSet(true, false)) {
354375
execute("stop");

0 commit comments

Comments
 (0)