Skip to content

Commit

Permalink
Capture error logs from compactor_runner script in the compactor logf…
Browse files Browse the repository at this point in the history
…ile (#3569)

When the compactor triggers the compactor_runner script, if there are any
failures before the script initializes its logger, the error log isn't logged
anywhere. This fix helps with capturing the error logs from compactor_runner
and logging them in the compactor logfile.
  • Loading branch information
SravanthiAshokKumar committed Mar 25, 2023
1 parent 84640ba commit f397b2d
Showing 1 changed file with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package org.corfudb.infrastructure;

import org.apache.commons.io.IOUtils;
import org.corfudb.runtime.DistributedCheckpointer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
Expand Down Expand Up @@ -56,6 +58,20 @@ public void invokeCheckpointing() {
this.checkpointerProcess = pb.start();
this.isInvoked = true;
log.info("Triggered compactor jvm");

Thread commandLineThread = new Thread(() -> {
try {
String err = IOUtils.toString(checkpointerProcess.getErrorStream(), StandardCharsets.UTF_8);
if (err.length() > 0) {
log.error("Error occurred after invoking compactor jvm: {}", err);
}
} catch (IOException ex) {
log.error("Exception occurred while getting ErrorStream: ", ex);
}
});
commandLineThread.setDaemon(true);
commandLineThread.start();

return;
} catch (RuntimeException re) {
if (DistributedCheckpointer.isCriticalRuntimeException(re, i, MAX_COMPACTION_RETRIES)) {
Expand Down

0 comments on commit f397b2d

Please sign in to comment.