Skip to content

Commit

Permalink
Merge pull request #18128 from jakesmith/HPCC-30994-worker-jobid
Browse files Browse the repository at this point in the history
HPCC-30994 Ensure jobId's removed from log manager in worker

Reviewed-by: Gavin Halliday <[email protected]>
Merged-by: Gavin Halliday <[email protected]>
  • Loading branch information
ghalliday authored Dec 14, 2023
2 parents 6d0436a + 4f87ea9 commit 0e7f8de
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 24 deletions.
1 change: 1 addition & 0 deletions thorlcr/slave/slavmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1886,6 +1886,7 @@ class CJobListener : public CSimpleInterface
ILogMsgFilter *existingLogHandler = queryLogMsgManager()->queryMonitorFilter(logHandler);
dbgassertex(existingLogHandler);
verifyex(queryLogMsgManager()->changeMonitorFilterOwn(logHandler, getCategoryLogMsgFilter(existingLogHandler->queryAudienceMask(), existingLogHandler->queryClassMask(), maxLogDetail)));
queryLogMsgManager()->removeJobId(thorJob.queryJobID());
LogMsgJobId thorJobId = queryLogMsgManager()->addJobId(wuid);
thorJob.setJobID(thorJobId);
setDefaultJobId(thorJobId);
Expand Down
53 changes: 29 additions & 24 deletions thorlcr/slave/thslavemain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,24 +292,35 @@ class CReleaseMutex : public CSimpleInterface, public Mutex
ILogMsgHandler *startSlaveLog()
{
ILogMsgHandler *logHandler = nullptr;
#ifndef _CONTAINERIZED
StringBuffer fileName("thorslave");
Owned<IComponentLogFileCreator> lf = createComponentLogFileCreator(globals->queryProp("@logDir"), "thor");
StringBuffer slaveNumStr;
lf->setPostfix(slaveNumStr.append(mySlaveNum).str());
lf->setCreateAliasFile(false);
lf->setName(fileName.str());//override default filename
logHandler = lf->beginLogging();
if (!isContainerized())
{
StringBuffer fileName("thorslave");
Owned<IComponentLogFileCreator> lf = createComponentLogFileCreator(globals->queryProp("@logDir"), "thor");
StringBuffer slaveNumStr;
lf->setPostfix(slaveNumStr.append(mySlaveNum).str());
lf->setCreateAliasFile(false);
lf->setName(fileName.str());//override default filename
logHandler = lf->beginLogging();
#ifndef _DEBUG
// keep duplicate logging output to stderr to aide debugging
queryLogMsgManager()->removeMonitor(queryStderrLogMsgHandler());
// keep duplicate logging output to stderr to aide debugging
queryLogMsgManager()->removeMonitor(queryStderrLogMsgHandler());
#endif

LOG(MCdebugProgress, thorJob, "Opened log file %s", lf->queryLogFileSpec());
#else
setupContainerizedLogMsgHandler();
logHandler = queryStderrLogMsgHandler();
#endif
LOG(MCdebugProgress, thorJob, "Opened log file %s", lf->queryLogFileSpec());
}
else
{
setupContainerizedLogMsgHandler();
logHandler = queryStderrLogMsgHandler();
StringBuffer wuid;
if (getComponentConfigSP()->getProp("@workunit", wuid))
{
LogMsgJobId thorJobId = queryLogMsgManager()->addJobId(wuid);
thorJob.setJobID(thorJobId);
setDefaultJobId(thorJobId);
}
}

//setupContainerizedStorageLocations();
LOG(MCdebugProgress, thorJob, "Build %s", hpccBuildInfo.buildTag);
return logHandler;
Expand Down Expand Up @@ -385,12 +396,9 @@ int main( int argc, const char *argv[] )
usage();

mySlaveNum = globals->getPropInt("@slavenum", NotFound);
/* NB: in cloud/non-local storage mode, slave number is not known until after registration with the master
* For the time being log file names are based on their slave number, so can only start when known.
*/
ILogMsgHandler *slaveLogHandler = nullptr;
if (NotFound != mySlaveNum)
slaveLogHandler = startSlaveLog();
if (!isContainerized() && (NotFound == mySlaveNum))
throw makeStringException(0, "Slave number not specified (@slavenum)");
ILogMsgHandler *slaveLogHandler = startSlaveLog();

// In container world, SLAVE= will not be used
const char *slave = globals->queryProp("@slave");
Expand Down Expand Up @@ -427,9 +435,6 @@ int main( int argc, const char *argv[] )

if (RegisterSelf(masterEp))
{
if (!slaveLogHandler)
slaveLogHandler = startSlaveLog();

if (getExpertOptBool("slaveDaliClient"))
enableThorSlaveAsDaliClient();

Expand Down

0 comments on commit 0e7f8de

Please sign in to comment.