Skip to content

Commit

Permalink
HPCC-31020 Fix postmortem files overwriting one another.
Browse files Browse the repository at this point in the history
Signed-off-by: Jake Smith <[email protected]>
  • Loading branch information
jakesmith committed Dec 14, 2023
1 parent 597fd83 commit bb2486b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions initfiles/bin/check_executes
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ if [ $PMD_ALWAYS = true ] || [ $retVal -ne 0 ]; then
cp $f $POST_MORTEM_DIR/$f
echo "Copied $f to $POST_MORTEM_DIR/$f" | tee -a $POST_MORTEM_DIR/info.log
done
cp `ls -rt /tmp/postmortem.log.*` $POST_MORTEM_DIR
rm /tmp/postmortem.log.*
cp `ls -rt /tmp/postmortem.$progPid.log.*` $POST_MORTEM_DIR
rm /tmp/postmortem.$progPid.log.*
if [ -f core ]; then
echo "Generating info from core file to $POST_MORTEM_DIR/info.log" | tee -a $POST_MORTEM_DIR/info.log
gdb -batch -ix /opt/HPCCSystems/bin/.gdbinit -x /opt/HPCCSystems/bin/post-mortem-gdb ${PMD_PROGNAME} core 2>$POST_MORTEM_DIR/info.err >>$POST_MORTEM_DIR/info.log
Expand Down
7 changes: 6 additions & 1 deletion system/jlib/jlog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2480,7 +2480,12 @@ void setupContainerizedLogMsgHandler()
unsigned postMortemLines = logConfig->getPropInt(capturePostMortemAtt, 0);
if (postMortemLines)
{
ILogMsgHandler *fileMsgHandler = getPostMortemLogMsgHandler("/tmp/postmortem.log", postMortemLines, MSGFIELD_STANDARD);
// augment postmortem files with <pid> to avoid clashes where multiple processes are running within
// same process space, e.g. hthor processes running in same k8s container
unsigned pid = GetCurrentProcessId();
VStringBuffer portMortemFileBase("/tmp/postmortem.%u.log", pid);

ILogMsgHandler *fileMsgHandler = getPostMortemLogMsgHandler(portMortemFileBase, postMortemLines, MSGFIELD_STANDARD);
queryLogMsgManager()->addMonitorOwn(fileMsgHandler, getCategoryLogMsgFilter(MSGAUD_all, MSGCLS_all, TopDetail));
}
}
Expand Down

0 comments on commit bb2486b

Please sign in to comment.