server
server copied to clipboard
Draft: Add option to suppress repeated error log messages
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 behavior
of 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).
2024-10-04 22:13:01 5 [Warning] Access denied for user 'foo'@'localhost' (using password: YES)
2024-10-04 22:13:04 6 [Warning] Access denied for user 'foo'@'localhost' (using password: YES)
2024-10-04 22:13:05 7 [Warning] Access denied for user 'foo'@'localhost' (using password: YES)
2024-10-04 22:13:06 8 [Warning] Access denied for user 'foo'@'localhost' (using password: YES)
2024-10-04 22:13:22 9 [Warning] Access denied for user 'bar'@'localhost' (using password: YES)```
Suppressing errors after 3 identical repetitions.
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)
## Release Notes
[WIP]
## How can this PR be tested?
[WIP: writing MTR tests]
<!--
Tick one of the following boxes [x] to help us understand if the base branch for the PR is correct.
see [CODING_STANDARDS.md](https://github.com/MariaDB/server/blob/-/CODING_STANDARDS.md) for the latest versions.
-->
## Basing the PR against the correct MariaDB version
- [x] *This is a new feature or a refactoring, and the PR is based against the `main` branch.*
<!--
All code merged into the MariaDB codebase must meet a quality standard and coding style.
Maintainers are happy to point out inconsistencies but in order to speed up the review and merge process we ask you to check the CODING standards.
-->
## PR quality check
- [x] I checked the [CODING_STANDARDS.md](https://github.com/MariaDB/server/blob/-/CODING_STANDARDS.md) file and my PR conforms to this where appropriate.
- [x] For any trivial modifications to the PR, I am ok with the reviewer making the changes themselves.