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

Draft: Add option to suppress repeated error log messages #3565

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

robinnewhouse
Copy link
Contributor

@robinnewhouse robinnewhouse commented Oct 5, 2024

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.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

This change adds 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.

```
2024-04-25 21:38:03 0 [Note] /usr/local/mysql/bin/mariadbd: ready for connections.
Version: '11.4.2-MariaDB'  socket: '/tmp/mysql.sock'  port: 3306  Source distribution
2024-04-25 21:38:11 3 [Warning] Access denied for user 'foo'@'localhost' (using password: YES)
2024-04-25 21:38:28 8 [Warning] Previous error was emitted 5 times
2024-04-25 21:38:28 8 [Warning] Access denied for user 'bar'@'localhost' (using password: YES)
2024-04-25 21:38:36 13 [Warning] Previous error was emitted 5 times
2024-04-25 21:38:36 13 [Warning] Access denied for user 'foo'@'localhost' (using password: YES)
2024-04-25 21:38:41 14 [Warning] Access denied for user 'bar'@'localhost' (using password: YES)
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants