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

Improve exception serializing #35970

Merged
merged 3 commits into from
Jan 16, 2023
Merged

Conversation

juliusknorr
Copy link
Member

@juliusknorr juliusknorr commented Jan 3, 2023

Summary

Small improvement to not start serializing an exception during logging if the log level would skip it anyways. Noticed when seeing errors due to Nesting level too deep - recursive dependency? at /var/www/html/lib/private/Log/ExceptionSerializer.php#215 while there was no actual error logged when commenting out the argument cleanup

The second commit avoids such cases by handling the arguments first (which limits to a recursion depth of 5) before iterating over them for filtering for sensitive parameters.

Checklist

@juliusknorr juliusknorr requested review from a team, ArtificialOwl, icewind1991, blizzz and PVince81 and removed request for a team January 3, 2023 18:05
@juliusknorr juliusknorr added the 3. to review Waiting for reviews label Jan 3, 2023
@juliusknorr juliusknorr changed the title perf(logging): Return early when log level does not match before serializing an exception Improve exception serializing Jan 3, 2023
@szaimen szaimen added this to the Nextcloud 26 milestone Jan 3, 2023
@solracsf
Copy link
Member

solracsf commented Jan 4, 2023

Does this fix #32432 and #35413?

@juliusknorr
Copy link
Member Author

Does this fix #32432 and #35413?

Likely doesn't fix it but would lead to getting a proper error message instead of the generic error caused within the logging parts.

@juliusknorr
Copy link
Member Author

Or wait, it may still help if the error was not logged due to a lower log level.

@PhrozenByte
Copy link
Contributor

Should also fix (resp. circumvent) #23429

@juliusknorr juliusknorr force-pushed the perf/noid/exception-serializer branch from e0d92cd to 6c996ee Compare January 11, 2023 18:06
Copy link
Member

@ChristophWurst ChristophWurst left a comment

Choose a reason for hiding this comment

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

👍 :shipit: otherwise

@@ -312,6 +312,11 @@ public function logException(Throwable $exception, array $context = []) {
$app = $context['app'] ?? 'no app in context';
$level = $context['level'] ?? ILogger::ERROR;

$minLevel = $this->getLogLevel($context);
if ($level < $minLevel && !$this->crashReporters->hasReporters()) {
Copy link
Member

Choose a reason for hiding this comment

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

$this->crashReporters needs a null check

@juliusknorr juliusknorr force-pushed the perf/noid/exception-serializer branch from 6c996ee to ecf0793 Compare January 12, 2023 15:06
Copy link
Member

@blizzz blizzz left a comment

Choose a reason for hiding this comment

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

wondering about #35970 (comment)

This will avoid running into a Nesting level too deep error as the
encodeArg calls will limit potential recursive calls on the arguments to
a nesting level of 5

Signed-off-by: Julius Härtl <[email protected]>
@juliusknorr juliusknorr force-pushed the perf/noid/exception-serializer branch from ecf0793 to cf1bd0e Compare January 16, 2023 08:47
@juliusknorr juliusknorr removed the 3. to review Waiting for reviews label Jan 16, 2023
@juliusknorr juliusknorr added bug 4. to release Ready to be released and/or waiting for tests to finish performance 🚀 labels Jan 16, 2023
@juliusknorr juliusknorr merged commit 8557c61 into master Jan 16, 2023
@juliusknorr juliusknorr deleted the perf/noid/exception-serializer branch January 16, 2023 13:00
@juliusknorr
Copy link
Member Author

/backport 7daa20d to stable25

@juliusknorr
Copy link
Member Author

/backport 7daa20d to stable24

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4. to release Ready to be released and/or waiting for tests to finish bug performance 🚀
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants