Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HPCC-31294 Refactor the way job ids are passed to the logging #18304

Merged
merged 1 commit into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion common/dllserver/dllserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ ILoadedDllEntry * DllServerBase::doLoadDll(const char * name, DllLocationType ty
location->getDllFilename(rfile);
StringBuffer x;
rfile.getPath(x);
LOG(MCdebugInfo, unknownJob, "Loading dll (%s) from location %s", name, x.str());
LOG(MCdebugInfo, "Loading dll (%s) from location %s", name, x.str());
return createDllEntry(x.str(), false, NULL, resourcesOnly);
}

Expand Down
12 changes: 6 additions & 6 deletions common/environment/environment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1877,15 +1877,15 @@ bool CLocalEnvironment::getRunInfo(IStringVal & path, IStringVal & dir, const ch
Owned<IConstMachineInfo> machine = getMachineByAddress(machineaddr);
if (!machine)
{
LOG(MCdebugInfo, unknownJob, "Unable to find machine for %s", machineaddr);
LOG(MCdebugInfo, "Unable to find machine for %s", machineaddr);
return false;
}

StringAttr targetdomain;
Owned<IConstDomainInfo> domain = machine->getDomain();
if (!domain)
{
LOG(MCdebugInfo, unknownJob, "Unable to find domain for %s", machineaddr);
LOG(MCdebugInfo, "Unable to find domain for %s", machineaddr);
return false;
}

Expand All @@ -1896,7 +1896,7 @@ bool CLocalEnvironment::getRunInfo(IStringVal & path, IStringVal & dir, const ch
Owned<IConstInstanceInfo> instance = getInstance(tag, version, targetdomain);
if (!instance)
{
LOG(MCdebugInfo, unknownJob, "Unable to find process %s for domain %s", tag, targetdomain.get());
LOG(MCdebugInfo, "Unable to find process %s for domain %s", tag, targetdomain.get());
return false;
}
return instance->getRunInfo(path,dir,defprogname);
Expand Down Expand Up @@ -1944,7 +1944,7 @@ IConstDropZoneInfo * CLocalEnvironment::getDropZoneByAddressPath(const char * ne
unsigned dropzonePathLen = _MAX_PATH + 1;

#ifdef _DEBUG
LOG(MCdebugInfo, unknownJob, "Netaddress: '%s', targetFilePath: '%s'", netaddress, targetFilePath);
LOG(MCdebugInfo, "Netaddress: '%s', targetFilePath: '%s'", netaddress, targetFilePath);
#endif
// Check the directory path first

Expand Down Expand Up @@ -1973,7 +1973,7 @@ IConstDropZoneInfo * CLocalEnvironment::getDropZoneByAddressPath(const char * ne
#ifdef _DEBUG
StringBuffer serverIpString;
serverIP.getHostText(serverIpString);
LOG(MCdebugInfo, unknownJob, "Listed server: '%s', IP: '%s'", dropzoneServer.str(), serverIpString.str());
LOG(MCdebugInfo, "Listed server: '%s', IP: '%s'", dropzoneServer.str(), serverIpString.str());
#endif
if (strisame(netaddress, dropzoneServer) || targetIp.ipequals(serverIP))
{
Expand Down Expand Up @@ -2551,7 +2551,7 @@ unsigned getAccessibleServiceURLList(const char *serviceType, std::vector<std::s
Owned<IPropertyTreeIterator> espBindingIter = espProcessIter->query().getElements("EspBinding");
ForEach(*espBindingIter)
{
xpath.setf("Software/EspService[@name=\"%s\"]/Properties/@type", espBindingIter->query().queryProp("@service"));
xpath.setf("Software/EspService[@name=\"%s\"]/Properties/@type", espBindingIter->query().queryProp("@service"));

if (strisame(env->queryProp(xpath), serviceType))
{
Expand Down
48 changes: 24 additions & 24 deletions common/remote/rmtspawn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ ISocket *spawnRemoteChild(SpawnKind kind, const char * exe, const SocketEndpoint

if (abort && abort->abortRequested())
{
LOG(MCdetailDebugInfo, unknownJob, "Action aborted before connecting to slave (%3d)", replyTag);
LOG(MCdetailDebugInfo, "Action aborted before connecting to slave (%3d)", replyTag);
return NULL;
}

Expand Down Expand Up @@ -169,7 +169,7 @@ ISocket *spawnRemoteChild(SpawnKind kind, const char * exe, const SocketEndpoint
unsigned attempts = 20;
SocketEndpoint connectEP(childEP);
connectEP.port = port;
LOG(MCdetailDebugInfo, unknownJob, "Start connect to correct slave (%3d)", replyTag);
LOG(MCdetailDebugInfo, "Start connect to correct slave (%3d)", replyTag);
IException * error = NULL;
ISocket * result = NULL;
while (!result && attempts)
Expand All @@ -178,7 +178,7 @@ ISocket *spawnRemoteChild(SpawnKind kind, const char * exe, const SocketEndpoint
{
StringBuffer tmp;
connectEP.getEndpointHostText(tmp);
LOG(MCdetailDebugInfo, unknownJob, "Try to connect to slave %s",tmp.str());
LOG(MCdetailDebugInfo, "Try to connect to slave %s",tmp.str());
Owned<ISocket> socket = ISocket::connect_wait(connectEP,MASTER_CONNECT_SLAVE_TIMEOUT);
if (socket)
{
Expand All @@ -202,7 +202,7 @@ ISocket *spawnRemoteChild(SpawnKind kind, const char * exe, const SocketEndpoint
if (connected)
{
assertex(slaveTag == replyTag);
LOG(MCdetailDebugInfo, unknownJob, "Connected to correct slave (%3d)", replyTag);
LOG(MCdetailDebugInfo, "Connected to correct slave (%3d)", replyTag);
result = socket.getClear();
break;
}
Expand All @@ -218,9 +218,9 @@ ISocket *spawnRemoteChild(SpawnKind kind, const char * exe, const SocketEndpoint
break;
}
if (slaveKind != kind)
LOG(MCdetailDebugInfo, unknownJob, "Connected to wrong kind of slave (%d,%d/%d) - try again later",connected,replyTag,slaveTag);
LOG(MCdetailDebugInfo, "Connected to wrong kind of slave (%d,%d/%d) - try again later",connected,replyTag,slaveTag);
else
LOG(MCdetailDebugInfo, unknownJob, "Failed to connect to correct slave (%d,%d/%d) - try again later",connected,replyTag,slaveTag);
LOG(MCdetailDebugInfo, "Failed to connect to correct slave (%d,%d/%d) - try again later",connected,replyTag,slaveTag);

//Wrong slave listening, need to leave time for the other, don't count as an attempt
MilliSleep(fastRand() % 5000 + 5000);
Expand All @@ -230,7 +230,7 @@ ISocket *spawnRemoteChild(SpawnKind kind, const char * exe, const SocketEndpoint
StringBuffer s;
s.appendf("Retry after exception talking to slave (%d): ",replyTag);
e->errorMessage(s);
LOG(MCdetailDebugInfo, unknownJob, "%s", s.str());
LOG(MCdetailDebugInfo, "%s", s.str());
e->Release();
//Probably another element just connected, and the listening socket has just been killed.
//So try again. Wait just long enough to give another thread a chance.
Expand All @@ -241,7 +241,7 @@ ISocket *spawnRemoteChild(SpawnKind kind, const char * exe, const SocketEndpoint
catch (IException * e)
{
StringBuffer s;
LOG(MCdetailDebugInfo, unknownJob, e, s.appendf("Failed to connect to slave (%d) (try again): ", replyTag).str());
LOG(MCdetailDebugInfo, e, s.appendf("Failed to connect to slave (%d) (try again): ", replyTag).str());
e->Release();
// No socket listening or contention - try again fairly soon
MilliSleep(fastRand()%400+100);
Expand Down Expand Up @@ -288,7 +288,7 @@ bool CRemoteParentInfo::processCommandLine(int argc, const char * * argv, String
void CRemoteParentInfo::log()
{
StringBuffer temp;
LOG(MCdebugProgress, unknownJob, "Starting remote slave. Master=%s reply=%d port=%d", parent.getEndpointHostText(temp).str(), replyTag, port);
LOG(MCdebugProgress, "Starting remote slave. Master=%s reply=%d port=%d", parent.getEndpointHostText(temp).str(), replyTag, port);
}

bool CRemoteParentInfo::sendReply(unsigned version)
Expand All @@ -300,7 +300,7 @@ bool CRemoteParentInfo::sendReply(unsigned version)
{
try
{
LOG(MCdetailDebugInfo, unknownJob, "Ready to listen. reply=%d port=%d", replyTag, port);
LOG(MCdetailDebugInfo, "Ready to listen. reply=%d port=%d", replyTag, port);
Owned<ISocket> listen = ISocket::create(port, 1);
if (listen)
{
Expand All @@ -313,11 +313,11 @@ bool CRemoteParentInfo::sendReply(unsigned version)
{
try
{
LOG(MCdetailDebugInfo, unknownJob, "Ready to accept connection. reply=%d", replyTag);
LOG(MCdetailDebugInfo, "Ready to accept connection. reply=%d", replyTag);

if (!listen->wait_read(SLAVE_LISTEN_FOR_MASTER_TIMEOUT))
{
LOG(MCdetailDebugInfo, unknownJob, "Gave up waiting for a connection. reply=%d", replyTag);
LOG(MCdetailDebugInfo, "Gave up waiting for a connection. reply=%d", replyTag);
return false;
}

Expand All @@ -333,7 +333,7 @@ bool CRemoteParentInfo::sendReply(unsigned version)
buffer.read(connectTag);
masterIP.getHostText(masterIPtext.clear());

LOG(MCdetailDebugInfo, unknownJob, "Process incoming connection. reply=%d got(%d,%s)", replyTag,connectTag,masterIPtext.str());
LOG(MCdetailDebugInfo, "Process incoming connection. reply=%d got(%d,%s)", replyTag,connectTag,masterIPtext.str());

same = (kind == connectKind) && masterIP.ipequals(parent) && (connectTag == replyTag);
}
Expand All @@ -344,7 +344,7 @@ bool CRemoteParentInfo::sendReply(unsigned version)
//can remove when all .exes have new code.
if (connectKind != kind)
{
LOG(MCdetailDebugInfo, unknownJob, "Connection for wrong slave kind (%u vs %u)- ignore", connectKind, kind);
LOG(MCdetailDebugInfo, "Connection for wrong slave kind (%u vs %u)- ignore", connectKind, kind);
}
}

Expand All @@ -358,12 +358,12 @@ bool CRemoteParentInfo::sendReply(unsigned version)
if (same)
{
socket.setown(connect.getClear());
LOG(MCdetailDebugInfo, unknownJob, "Connection matched - continue....");
LOG(MCdetailDebugInfo, "Connection matched - continue....");
return true;
}
if ((connectKind == kind) && (version != connectVersion))
{
LOG(MCdebugInfo, unknownJob, "Version mismatch - terminating slave process expected %d got %d", version, connectVersion);
LOG(MCdebugInfo, "Version mismatch - terminating slave process expected %d got %d", version, connectVersion);
return false;
}
}
Expand Down Expand Up @@ -419,7 +419,7 @@ void CRemoteSlave::run(int argc, const char * * argv)
logFile.append(".log");
attachStandardFileLogMsgMonitor(logFile.str(), 0, MSGFIELD_STANDARD, MSGAUD_all, MSGCLS_all, TopDetail, LOGFORMAT_table, true, true);
queryLogMsgManager()->removeMonitor(queryStderrLogMsgHandler()); // no point logging output to screen if run remote!
LOG(MCdebugProgress, unknownJob, "Starting %s %s %s %s %s %s %s",slaveName.get(),(argc>1)?argv[1]:"",(argc>2)?argv[2]:"",(argc>3)?argv[3]:"",(argc>4)?argv[4]:"",(argc>5)?argv[5]:"",(argc>6)?argv[6]:"");
LOG(MCdebugProgress, "Starting %s %s %s %s %s %s %s",slaveName.get(),(argc>1)?argv[1]:"",(argc>2)?argv[2]:"",(argc>3)?argv[3]:"",(argc>4)?argv[4]:"",(argc>5)?argv[5]:"",(argc>6)?argv[6]:"");
#else
setupContainerizedLogMsgHandler();
#endif
Expand Down Expand Up @@ -485,7 +485,7 @@ void CRemoteSlave::run(int argc, const char * * argv)
}
catch (RELEASE_CATCH_ALL)
{
LOG(MCwarning, unknownJob, "Server seems to have crashed - close done gracefully");
LOG(MCwarning, "Server seems to have crashed - close done gracefully");
error.setown(MakeStringException(999, "Server seems to have crashed - close done gracefully"));
}

Expand All @@ -495,25 +495,25 @@ void CRemoteSlave::run(int argc, const char * * argv)
msg.append(results);
catchWriteBuffer(masterSocket, msg);

LOG(MCdebugProgress, unknownJob, "Results sent from slave %d", info.replyTag);
LOG(MCdebugProgress, "Results sent from slave %d", info.replyTag);

//Acknowledgement before closing down...
msg.clear();
if (catchReadBuffer(masterSocket, msg, RMTTIME_RESPONSE_MASTER))
{
LOG(MCdebugProgress, unknownJob, "Terminate acknowledgement received from master for slave %d", info.replyTag);
LOG(MCdebugProgress, "Terminate acknowledgement received from master for slave %d", info.replyTag);
msg.read(ok);
assertex(ok);
}
else
LOG(MCdebugProgress, unknownJob, "No terminate acknowledgement received from master for slave %d", info.replyTag);
LOG(MCdebugProgress, "No terminate acknowledgement received from master for slave %d", info.replyTag);

if (error)
break;
timeOut = 24*60*60*1000;
} while (stayAlive);

LOG(MCdebugProgress, unknownJob, "Terminate acknowledgement received from master for slave %d", info.replyTag);
LOG(MCdebugProgress, "Terminate acknowledgement received from master for slave %d", info.replyTag);
}
}
catch (IException * e)
Expand All @@ -522,7 +522,7 @@ void CRemoteSlave::run(int argc, const char * * argv)
e->Release();
}
}
LOG(MCdebugProgress, unknownJob, "Stopping %s", slaveName.get());
LOG(MCdebugProgress, "Stopping %s", slaveName.get());
}


Expand Down Expand Up @@ -570,7 +570,7 @@ void checkForRemoteAbort(ISocket * socket)

bool sendRemoteAbort(ISocket * socket)
{
LOG(MCdebugInfo, unknownJob, "Send abort to remote slave (%d)", isAborting());
LOG(MCdebugInfo, "Send abort to remote slave (%d)", isAborting());

MemoryBuffer msg;
msg.append(true);
Expand Down
6 changes: 3 additions & 3 deletions common/thorhelper/roxiehelper.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@ interface IRoxieContextLogger : extends IContextLogger
{
// Override base interface with versions that add prefix
// We could consider moving some or all of these down into IContextLogger
virtual void CTXLOGva(const LogMsgCategory & cat, const LogMsgJobInfo & job, LogMsgCode code, const char *format, va_list args) const override __attribute__((format(printf,5,0)))
virtual void CTXLOGva(const LogMsgCategory & cat, LogMsgCode code, const char *format, va_list args) const override __attribute__((format(printf,4,0)))
{
StringBuffer text, prefix;
getLogPrefix(prefix);
text.valist_appendf(format, args);
CTXLOGa(LOG_TRACING, cat, job, code, prefix.str(), text.str());
CTXLOGa(LOG_TRACING, cat, code, prefix.str(), text.str());
}
virtual void logOperatorExceptionVA(IException *E, const char *file, unsigned line, const char *format, va_list args) const __attribute__((format(printf,5,0)))
{
Expand All @@ -77,7 +77,7 @@ interface IRoxieContextLogger : extends IContextLogger

virtual StringBuffer &getLogPrefix(StringBuffer &ret) const = 0;
virtual bool isIntercepted() const = 0;
virtual void CTXLOGa(TracingCategory category, const LogMsgCategory & cat, const LogMsgJobInfo & job, LogMsgCode code, const char *prefix, const char *text) const = 0;
virtual void CTXLOGa(TracingCategory category, const LogMsgCategory & cat, LogMsgCode code, const char *prefix, const char *text) const = 0;
void CTXLOGae(IException *E, const char *file, unsigned line, const char *prefix, const char *format, ...) const __attribute__((format(printf, 6, 7)));
virtual void CTXLOGaeva(IException *E, const char *file, unsigned line, const char *prefix, const char *format, va_list args) const = 0;
virtual void CTXLOGl(LogItem *) const = 0;
Expand Down
9 changes: 4 additions & 5 deletions common/thorhelper/thorcommon.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -398,14 +398,14 @@ class CStatsContextLogger : public CSimpleInterfaceOf<IContextLogger>
Owned<ISpan> activeSpan = getNullSpan();
mutable CRuntimeStatisticCollection stats;
public:
CStatsContextLogger(const CRuntimeStatisticCollection &_mapping, const LogMsgJobInfo & _job=unknownJob) : job(_job), stats(_mapping) {}
CStatsContextLogger(const CRuntimeStatisticCollection &_mapping) : stats(_mapping) {}
void reset()
{
stats.reset();
}
virtual void CTXLOGva(const LogMsgCategory & cat, const LogMsgJobInfo & job, LogMsgCode code, const char *format, va_list args) const override __attribute__((format(printf,5,0)))
virtual void CTXLOGva(const LogMsgCategory & cat, LogMsgCode code, const char *format, va_list args) const override __attribute__((format(printf,4,0)))
{
VALOG(cat, job, code, format, args);
VALOG(cat, code, format, args);
}
virtual void logOperatorExceptionVA(IException *E, const char *file, unsigned line, const char *format, va_list args) const __attribute__((format(printf,5,0)))
{
Expand All @@ -419,7 +419,7 @@ class CStatsContextLogger : public CSimpleInterfaceOf<IContextLogger>
E->errorMessage(ss.append(": "));
if (format)
ss.append(": ").valist_appendf(format, args);
LOG(MCoperatorProgress, queryJob(), "%s", ss.str());
LOG(MCoperatorProgress, "%s", ss.str());
}
virtual void noteStatistic(StatisticKind kind, unsigned __int64 value) const override
{
Expand Down Expand Up @@ -485,7 +485,6 @@ class CStatsContextLogger : public CSimpleInterfaceOf<IContextLogger>
{
previous.updateDelta(to, stats);
}
virtual const LogMsgJobInfo & queryJob() const override { return job; }
};

extern THORHELPER_API bool isActivitySink(ThorActivityKind kind);
Expand Down
2 changes: 1 addition & 1 deletion common/thorhelper/thorsoapcall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1950,7 +1950,7 @@ class CWSCAsyncFor : implements IWSCAsyncFor, public CInterface, public CAsyncFo
if (httpheaders && *httpheaders)
{
if (soapTraceLevel > 6 || master->logXML)
master->logctx.mCTXLOG("%s: Adding HTTP Headers(%s)", master->wscCallTypeText(), httpheaders);
master->logctx.mCTXLOG("%s: Adding HTTP Headers(%s)", master->wscCallTypeText(), httpheaders);
request.append(httpheaders);
}

Expand Down
Loading
Loading