Draft: Add option to suppress repeated error log messages #3565
+93
−4
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I am seeking feedback on this solution before going any further with it. I would like to limit the rate of error log messages that is different than fully suppressing them like mysql's log_error_suppression_list or configuring the verbosity level
Description
Add a new configuration option
log_suppress_repeated_errors
that allows users to control the behaviorof error logging. When this option is set to a non-zero value, the
server will suppress repeated identical error messages after the
specified number of occurrences.
This is implemented by tracking the last logged error message and its
count. If a new message matches the previous one, and the count has not
reached the suppression limit, the message is not logged again. Once a
new unique message is encountered, the previous message's count is
logged, and the new message is printed.
The suppression can be disabled by setting the option to 0.
Default behaviour (log_suppress_repeated_errors = 0).
MariaDB [(none)]> SET GLOBAL log_suppress_repeated_errors = 3;
2024-10-04 22:14:06 12 [Warning] Access denied for user 'foo'@'localhost' (using password: YES)
2024-10-04 22:14:09 13 [Warning] Access denied for user 'foo'@'localhost' (using password: YES)
2024-10-04 22:14:13 14 [Warning] Access denied for user 'foo'@'localhost' (using password: YES)
2024-10-04 22:14:29 19 [Warning] The following message was emitted 7 times (repeated instances suppressed): Access denied for user 'foo'@'localhost' (using password: YES)
2024-10-04 22:14:29 19 [Warning] Access denied for user 'bar'@'localhost' (using password: YES)