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

Conversation

ghalliday
Copy link
Member

@ghalliday ghalliday commented Feb 16, 2024

Type of change:

  • This change is a bug fix (non-breaking change which fixes an issue).
  • This change is a new feature (non-breaking change which adds functionality).
  • This change improves the code (refactor or other change that does not change the functionality)
  • This change fixes warnings (the fix does not alter the functionality or the generated code)
  • This change is a breaking change (fix or feature that will cause existing behavior to change).
  • This change alters the query API (existing queries will have to be recompiled)

Checklist:

  • My code follows the code style of this project.
    • My code does not create any new warnings from compiler, build system, or lint.
  • The commit message is properly formatted and free of typos.
    • The commit message title makes sense in a changelog, by itself.
    • The commit is signed.
  • My change requires a change to the documentation.
    • I have updated the documentation accordingly, or...
    • I have created a JIRA ticket to update the documentation.
    • Any new interfaces or exported functions are appropriately commented.
  • I have read the CONTRIBUTORS document.
  • The change has been fully tested:
    • I have added tests to cover my changes.
    • All new and existing tests passed.
    • I have checked that this change does not introduce memory leaks.
    • I have used Valgrind or similar tools to check for potential issues.
  • I have given due consideration to all of the following potential concerns:
    • Scalability
    • Performance
    • Security
    • Thread-safety
    • Cloud-compatibility
    • Premature optimization
    • Existing deployed queries will not be broken
    • This change fixes the problem, not just the symptom
    • The target branch of this pull request is appropriate for such a change.
  • There are no similar instances of the same problem that should be addressed
    • I have addressed them here
    • I have raised JIRA issues to address them separately
  • This is a user interface / front-end modification
    • I have tested my changes in multiple modern browsers
    • The component(s) render as expected

Smoketest:

  • Send notifications about my Pull Request position in Smoketest queue.
  • Test my draft Pull Request.

Testing:

Copy link

@ghalliday
Copy link
Member Author

@jakesmith @richardkchapman what are your thoughts? This was triggered by a discussion with @rpastrana about how to add trace ids into the logging, which made me realise all this code could be cleaned up.
I suspect this is too drastic a refactoring for 9.4.x, and should target master instead. If so I will delay merging because it is likely to cause upmerge problems.

@jakesmith
Copy link
Member

Copy link
Member

@jakesmith jakesmith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ghalliday - looks eminently sensible to me.

A couple of recursive definitions, and some spurious spaces introduced.

@@ -1289,15 +1285,15 @@ void LogMsgPrepender::report(const LogMsgCategory & cat, const char * format, ..
buff.append(file).append("(").append(line).append(") : ").append(format);
va_list args;
va_start(args, format);
queryLogMsgManager()->report_va(cat, unknownJob, buff.str(), args);
queryLogMsgManager()->report_va(cat, buff.str(), args);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

trivial/formatting: double space

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, an unfortunate side-effect of a global search and replace that didn't include the trailing space. I'll try and fix.

va_end(args);
}

void LogMsgPrepender::report_va(const LogMsgCategory & cat, const char * format, va_list args)
{
StringBuffer buff;
buff.append(file).append("(").append(line).append(") : ").append(format);
queryLogMsgManager()->report_va(cat, unknownJob, buff.str(), args);
queryLogMsgManager()->report_va(cat, buff.str(), args);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

trivial/formatting: double space

txt.append(prefix).append(" : ");
exception->errorMessage(txt);
queryLogMsgManager()->report(cat, job, exception->errorCode(), "%s(%d) : %s", file, line, txt.str());
queryLogMsgManager()->report(cat, exception->errorCode(), "%s", buff.str());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

trivial/formatting: double space

..and a number of others in changes below.

va_end(args);
}
void ctxlogReportVA(const LogMsgCategory & cat, LogMsgCode code, const char * format, va_list args)
{
ctxlogReportVA(cat, unknownJob, code, format, args);
ctxlogReportVA(cat, code, format, args);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the recursive call.
Should it be:

    queryLogMsgManager()->report_va(cat, code, format, args);

StringBuffer buff;
e->errorMessage(buff);
ctxlogReport(cat, job, e->errorCode(), "%s%s%s", prefix ? prefix : "", prefix ? prefix : " : ", buff.str());
ctxlogReport(cat, e, prefix);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also recursive I think. Should it be:

    queryLogMsgManager()->report(cat, e, prefix);
``` @

@ghalliday ghalliday changed the base branch from candidate-9.4.x to master March 8, 2024 13:58
@ghalliday ghalliday closed this Mar 8, 2024
@ghalliday ghalliday reopened this Mar 8, 2024
Copy link

github-actions bot commented Mar 8, 2024

https://track.hpccsystems.com/browse/HPCC-31294
This pull request is already registered

@ghalliday
Copy link
Member Author

@jakesmith I have now rebased this, squashed the previous commits, and added a couple more commits to clean the code up further

@ghalliday ghalliday requested a review from jakesmith March 8, 2024 13:59
thorJob.setJobID(thorJobId);
setDefaultJobId(thorJobId);
activeJobName.clear();
activeJobName.set(wuid);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

trivial: it's fine as it is, looking at these 2 lines, it made me think 'set' should implicitly clear if it needs to.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed

Copy link
Member

@jakesmith jakesmith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ghalliday - I can't spot any issues (1 trivial comment).

@richardkchapman
Copy link
Member

I did not spot any issues

@ghalliday ghalliday changed the base branch from master to candidate-9.6.x March 14, 2024 13:25
@ghalliday ghalliday force-pushed the refactorLogJob branch 2 times, most recently from 3cda6cf to 50d4fdd Compare March 14, 2024 14:35
Signed-off-by: Gavin Halliday <gavin.halliday@lexisnexis.com>
@ghalliday ghalliday merged commit 1b9763f into hpcc-systems:candidate-9.6.x Mar 15, 2024
24 of 30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants