Skip to content

HPCC-33885 Ensure persistent components do not restart, but pick up logging config changes #19783

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

Conversation

streeterd
Copy link
Contributor

@streeterd streeterd commented Apr 24, 2025

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:

@streeterd streeterd self-assigned this Apr 24, 2025
Copy link

Jira Issue: https://hpccsystems.atlassian.net//browse/HPCC-33885

Jirabot Action Result:
Workflow Transition To: Merge Pending
Additional PR: #19783

@streeterd streeterd force-pushed the HPCC-33885_Log_cfg_chgs_dont_restart_persist_pods2 branch 2 times, most recently from 54c06d8 to a3e6458 Compare April 24, 2025 07:49
@streeterd streeterd changed the base branch from master to candidate-9.12.x April 24, 2025 07:49
@streeterd streeterd force-pushed the HPCC-33885_Log_cfg_chgs_dont_restart_persist_pods2 branch 4 times, most recently from e9fa1b7 to dbea252 Compare April 24, 2025 11:23
@streeterd streeterd requested a review from Copilot April 24, 2025 11:24
@streeterd streeterd marked this pull request as ready for review April 24, 2025 11:24
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR addresses HPCC-33885 by enhancing the logging configuration to allow persistent components to update their logging configuration on the fly without restarting. Key changes include:

  • Adding a new pure virtual method queryFormatType() to log handler classes in jlog.ipp.
  • Introducing queryMaxLinesToKeep() and setMaxLinesToKeep() in the ILogMsgHandler interface in jlog.hpp and their concrete implementations.
  • Updating the containerized logging setup in jlog.cpp to support on‑the‑fly configuration updates and dynamic postmortem log line adjustments.

Reviewed Changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 1 comment.

File Description
system/jlib/jlog.ipp Adds queryFormatType() method to log handler classes and adjusts maxLinesToKeep.
system/jlib/jlog.hpp Extends ILogMsgHandler interface with new max-lines methods and updates function signature.
system/jlib/jlog.cpp Refactors setupContainerizedLogMsgHandler to support live updates and adjusts postmortem handler logic.
Files not reviewed (1)
  • helm/hpcc/templates/_helpers.tpl: Language not supported

{
// Alow the first config update hook call to update the config as if it was not
Copy link
Preview

Copilot AI Apr 24, 2025

Choose a reason for hiding this comment

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

Typo in comment: 'Alow' should be corrected to 'Allow'.

Suggested change
// Alow the first config update hook call to update the config as if it was not
// Allow the first config update hook call to update the config as if it was not

Copilot uses AI. Check for mistakes.

@streeterd streeterd requested a review from jakesmith April 24, 2025 11:33
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.

@streeterd - haven't looked beyond the unintended release of a change to plugins/CMakeLists.txt ..

Please self-review in github before tagging, to weed out issues like this.

@streeterd
Copy link
Contributor Author

@streeterd - haven't looked beyond the unintended release of a change to plugins/CMakeLists.txt ..

Please self-review in github before tagging, to weed out issues like this.

Removed in 6522db7

@streeterd streeterd requested a review from jakesmith April 24, 2025 12:26
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.

@streeterd - discussed offline. I think this needs to be simplified with setupContainerizedLogging split into 2 functions, with a configureHandlers() or similarly named, called from the setup function and installed as a hook.

Such that configureHandlers only changes properties of the already created handlers.
Should still complain if format detection spotted.

A postmortem maxlines change will need to be coded carefully.
In fact, it may be best to do that as a follow on PR - smaller PR's are better PR's.

@streeterd streeterd marked this pull request as draft April 25, 2025 15:16
@streeterd streeterd force-pushed the HPCC-33885_Log_cfg_chgs_dont_restart_persist_pods2 branch from 5dc4dc7 to ca893c0 Compare April 28, 2025 09:26
@@ -1142,7 +1142,7 @@
"description": "Number of log entries to drop from the log queue when it is full. Disabled if 0, or if queueLength is 0",
"default": 0
},
"dataFormat": {
"format": {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Correct the logging format property name to format.

@streeterd streeterd force-pushed the HPCC-33885_Log_cfg_chgs_dont_restart_persist_pods2 branch 2 times, most recently from 1479d7c to 2452fe9 Compare April 28, 2025 14:23
@streeterd streeterd marked this pull request as ready for review April 28, 2025 14:29
@streeterd streeterd requested a review from jakesmith April 28, 2025 14:29
@streeterd
Copy link
Contributor Author

The failure of the K8s Regression Suite is being resolved under PR: hpcc-systems/hpcc4j#815

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.

@streeterd - tagging you back for now, after pushing commit.

@@ -438,6 +438,7 @@ public:
int flush() { CriticalBlock block(crit); return fflush(handle); }
bool getLogName(StringBuffer &name) const { return false; }
offset_t getLogPosition(StringBuffer &name) const { return 0; }
virtual LogHandlerFormat queryFormatType() const = 0;
Copy link
Member

Choose a reason for hiding this comment

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

virtual is good, but it jars that other existing virtuals methods are not decorated like this. In cases like this, it's worth updating the other methods, rather than sacrifice the new code for consistency.

Copy link
Member

Choose a reason for hiding this comment

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

also, though not strictly needed for this change, I think it would be better to add to interface too (ILogMsgHandler), as it stands out as an anomaly otherwise.

And, given that, these should really all have 'override's on their definitions too

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jakesmith Fixed in 2991719

@streeterd streeterd force-pushed the HPCC-33885_Log_cfg_chgs_dont_restart_persist_pods2 branch from c98a810 to 2991719 Compare May 1, 2025 08:37
@streeterd streeterd requested a review from jakesmith May 1, 2025 08:37
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.

@streeterd - please see comments.

else if (streq(newFormatString, "table"))
newFormat = LOGFORMAT_table;
else
LOG(MCoperatorWarning, "JLog: Invalid log format configuration detected '%s'!", newFormatString);
Copy link
Member

Choose a reason for hiding this comment

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

OWARNLOG more concise

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 28782b7

@@ -2473,6 +2517,7 @@ void setupContainerizedLogMsgHandler()
queryLogMsgManager()->addMonitor(thePostMortemHandler, getCategoryLogMsgFilter(MSGAUD_all, MSGCLS_all, TopDetail));
}
Copy link
Member

Choose a reason for hiding this comment

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

there should be call after this line to updateStdErrLogHandler ..
as it stands, nothing is using the config properties at the outset..until there's an update.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 9ad9d66

@@ -912,6 +914,7 @@ extern jlib_decl ILogMsgHandler * queryStderrLogMsgHandler();
extern jlib_decl ILogMsgHandler * queryPostMortemLogMsgHandler();
extern jlib_decl bool copyPostMortemLogging(const char *target, bool clear);
extern jlib_decl void setupContainerizedLogMsgHandler();
bool configureHandlers(bool rejectOnTheFlyChanges);
Copy link
Member

Choose a reason for hiding this comment

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

missing extern jlib_decl

Copy link
Member

Choose a reason for hiding this comment

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

but actually this is old, should be removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 9ad9d66

bool needsPrep() const override { return false; }
void prep() override {}
void addToPTree(IPropertyTree * tree) const override;
virtual LogHandlerFormat queryFormatType() const override { return LOGFORMAT_json; };
Copy link
Member

Choose a reason for hiding this comment

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

please decorate other methods with 'virtual' too to be consistent.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 9ad9d66

int flush() override { return 0; }
bool getLogName(StringBuffer &name) const override { name.append(filename); return true; }
offset_t getLogPosition(StringBuffer &name) const override { CriticalBlock block(crit); name.append(filename); return fstr->tell(); }
LogHandlerFormat queryFormatType() const override { return LOGFORMAT_undefined; };
Copy link
Member

Choose a reason for hiding this comment

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

please decorate methods with 'virtual' as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 9ad9d66

int flush() override { return 0; }
bool getLogName(StringBuffer &name) const override { return false; }
offset_t getLogPosition(StringBuffer &logFileName) const override { return 0; }
LogHandlerFormat queryFormatType() const override { return LOGFORMAT_undefined; };
Copy link
Member

Choose a reason for hiding this comment

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

please decorate methods with 'virtual' as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 9ad9d66

void prep() override {}
void addToPTree(IPropertyTree * tree) const override;
unsigned queryMessageFields() const override { return MSGFIELD_all; }
void setMessageFields(unsigned _fields = MSGFIELD_all) override {}
Copy link
Member

Choose a reason for hiding this comment

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

please decorate methods with 'virtual' as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 9ad9d66

offset_t getLogPosition(StringBuffer &name) const { return 0; }
bool getLogName(StringBuffer &name) const override { return false; }
offset_t getLogPosition(StringBuffer &name) const override { return 0; }
LogHandlerFormat queryFormatType() const override { return LOGFORMAT_undefined; };
Copy link
Member

Choose a reason for hiding this comment

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

please decorate methods with 'virtual' as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 9ad9d66

void setupContainerizedLogMsgHandler()
// returns LOGFORMAT_undefined if format has not changed
// NB: returns LOGFORMAT_table if no format specified (i.e. this is the default)
LogHandlerFormat hasLogFormatChanged(const IPropertyTree *logConfig)
Copy link
Member

Choose a reason for hiding this comment

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

hasXX doesn't really make sense anymore, I suggest renaming to 'getConfigHandlerFormat'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 9ad9d66

@streeterd streeterd force-pushed the HPCC-33885_Log_cfg_chgs_dont_restart_persist_pods2 branch from d66e5a6 to 9ad9d66 Compare May 1, 2025 11:53
@streeterd streeterd requested a review from jakesmith May 1, 2025 11:54
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.

@streeterd - 1 trivial issue remaining (see comment).

virtual int flush() override { CriticalBlock block(crit); return fflush(handle); }
virtual bool getLogName(StringBuffer &name) const override { CriticalBlock block(crit); name.append(filename); return true; }
virtual offset_t getLogPosition(StringBuffer &name) const override { CriticalBlock block(crit); fflush(handle); name.append(filename); return ftell(handle); }
virtual LogHandlerFormat queryFormatType() const override { return LOGFORMAT_undefined; };
Copy link
Member

Choose a reason for hiding this comment

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

I missed one.. RollingFileLogMsgHandler is implicitly LOGFORMAT_table (see its handleMessage impl).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in e647cc9

@streeterd streeterd requested a review from jakesmith May 8, 2025 08:02
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.

@streeterd - a couple of minor comments.

if (newFormat != LOGFORMAT_undefined)
{
OWARNLOG("JLog: Ignoring log format configuration change on the fly, as it is not supported in a containerized environment");
return;
Copy link
Member

Choose a reason for hiding this comment

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

the message implies only the format change will be ignored, but the return means all changes will be ignored.
Should either say [all] logging configure update ignore (not just format), or continue to call updateStdErrLogHandler.

I think probably should just ignore format and continue to call udpateStdErrLogHandler.

Copy link
Member

@jakesmith jakesmith May 15, 2025

Choose a reason for hiding this comment

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

I meant still issue the warning that ignoring format change, but continue...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added code back in to warn if log format changes and carry on in 80f0769

switch (newFormat)
{
case LOGFORMAT_xml:
theStderrHandler = new HandleLogMsgHandlerXML(stderr, MSGFIELD_STANDARD);
Copy link
Member

Choose a reason for hiding this comment

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

is there a separate existing JIRA to fix the pre-existing leak here?
(Can you link it to this JIRA if so?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -2462,7 +2506,7 @@ void setupContainerizedLogMsgHandler()
UseSysLogForOperatorMessages();

unsigned postMortemLines = logConfig->getPropInt(capturePostMortemAtt, 0);
if (postMortemLines)
if (postMortemLines && !thePostMortemHandler)
Copy link
Member

Choose a reason for hiding this comment

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

adding && !thePostMortemHandler suggests, that it's valid to already be set.
If it were already set, then postMortemLines from config would be ignored.

I think best to remove this new check for now, but open a JIRA to support postMortemLines changing, and support it without recreating the handler, i.e. adding a method that sets it the existing handler, and manages increase/decrease/rollover carefully.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@streeterd streeterd requested a review from jakesmith May 14, 2025 08:09
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.

@streeterd - 1 comment re. removal of format change warning

@streeterd streeterd requested a review from jakesmith May 15, 2025 13:58
@@ -2442,6 +2442,12 @@ static void loggingSetupUpdate(const IPropertyTree *oldComponentConfiguration, c
return;
}

LogHandlerFormat newFormat = getConfigHandlerFormat(logConfig);
if (newFormat != LOGFORMAT_undefined)
{
Copy link
Member

Choose a reason for hiding this comment

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

trivial/style/don't change: normally we avoid { } for single line.

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.

@streeterd - looks good.

Please squash.

@streeterd streeterd force-pushed the HPCC-33885_Log_cfg_chgs_dont_restart_persist_pods2 branch from 80f0769 to 24201ce Compare May 15, 2025 15:34
@streeterd
Copy link
Contributor Author

@streeterd - looks good.

Please squash.

@jakesmith squashed

@jakesmith jakesmith requested a review from ghalliday May 16, 2025 14:50
@jakesmith
Copy link
Member

@ghalliday - please sanity check.

Copy link
Member

@ghalliday ghalliday left a comment

Choose a reason for hiding this comment

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

Looks good. Only a few trivial comments, not worth changing.

virtual LogHandlerFormat queryFormatType() const override
{
return LOGFORMAT_undefined;
};
Copy link
Member

Choose a reason for hiding this comment

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

trivial: extraneous semicolon

virtual int flush() override { return 0; }
virtual bool getLogName(StringBuffer &name __attribute__((unused))) const override { return false; }
virtual offset_t getLogPosition(StringBuffer &logFileName __attribute__((unused))) const override { return 0; };
virtual LogHandlerFormat queryFormatType() const override { return LOGFORMAT_undefined; };
Copy link
Member

Choose a reason for hiding this comment

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

similar extra ;, and on line above.

@@ -691,6 +691,7 @@ interface jlib_decl ILogMsgFilter : public IInterface

typedef enum
{
LOGFORMAT_undefined,
Copy link
Member

Choose a reason for hiding this comment

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

I think this ok, but I had to double check none of these values were serialized - because this changes all the values.

@ghalliday
Copy link
Member

@streeterd needs rebasing before it can be merged.

…ut restarts

Implement ability to change to table log format.
Add ability for on-the-fly logging configuration changes.
Validate on-the-fly logging configuration changes to prevent log format change.

Signed-off-by: Dave Streeter <[email protected]>
@streeterd streeterd force-pushed the HPCC-33885_Log_cfg_chgs_dont_restart_persist_pods2 branch from 24201ce to 4de8fc8 Compare May 21, 2025 12:15
@streeterd
Copy link
Contributor Author

@streeterd needs rebasing before it can be merged.

@ghalliday rebased on candidate-9.12.x

@ghalliday ghalliday merged commit 0c8a2ae into hpcc-systems:candidate-9.12.x May 22, 2025
54 of 55 checks passed
Copy link

Jirabot Action Result:
Added fix version: 9.12.6
Workflow Transition: 'Resolve issue'

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