MySQL 8.0.39
Source Code Documentation
|
Used for rate-limiting the slow query log. More...
#include <log.h>
Public Member Functions | |
Slow_log_throttle (ulong *threshold, mysql_mutex_t *lock, ulong window_usecs, log_summary_t logger, const char *msg) | |
bool | flush (THD *thd) |
Prepare and print a summary of suppressed lines to log. More... | |
bool | log (THD *thd, bool eligible) |
Top-level function. More... | |
Private Member Functions | |
void | new_window (ulonglong now) |
Start a new window. More... | |
void | print_summary (THD *thd, ulong suppressed, ulonglong print_lock_time, ulonglong print_exec_time) |
Actually print the prepared summary to log. More... | |
Private Attributes | |
Security_context | aggregate_sctx |
We're using our own (empty) security context during summary generation. More... | |
ulonglong | total_exec_time |
Total of the execution times of queries in this time-window for which we suppressed logging. More... | |
ulonglong | total_lock_time |
Total of the lock times of queries in this time-window for which we suppressed logging. More... | |
ulong * | rate |
A reference to the threshold ("no more than n log lines per ..."). More... | |
log_summary_t | log_summary |
The routine we call to actually log a line (our summary). More... | |
mysql_mutex_t * | LOCK_log_throttle |
Slow_log_throttle is shared between THDs. More... | |
Additional Inherited Members | |
Static Public Attributes inherited from Log_throttle | |
static const ulong | LOG_THROTTLE_WINDOW_SIZE = 60000000 |
We're rate-limiting messages per minute; 60,000,000 microsecs = 60s Debugging is less tedious with a window in the region of 5000000. More... | |
Protected Member Functions inherited from Log_throttle | |
void | new_window (ulonglong now) |
Start a new window. More... | |
bool | inc_log_count (ulong rate) |
Increase count of logs we're handling. More... | |
bool | in_window (ulonglong now) const |
Check whether we're still in the current window. More... | |
ulong | prepare_summary (ulong rate) |
Prepare a summary of suppressed lines for logging. More... | |
Log_throttle (ulong window_usecs, const char *msg) | |
Protected Attributes inherited from Log_throttle | |
const char * | summary_template |
Template for the summary line. More... | |
Used for rate-limiting the slow query log.
Used for rate-limiting a error logs.
Slow_log_throttle::Slow_log_throttle | ( | ulong * | threshold, |
mysql_mutex_t * | lock, | ||
ulong | window_usecs, | ||
log_summary_t | logger, | ||
const char * | msg | ||
) |
threshold | suppress after this many queries ... |
lock | mutex to use for consistency of calculations |
window_usecs | ... in this many micro-seconds |
logger | call this function to log a single line (our summary) |
msg | use this template containing lu as only non-literal |
bool Slow_log_throttle::flush | ( | THD * | thd | ) |
Prepare and print a summary of suppressed lines to log.
(For now, slow query log.) The summary states the number of queries that were qualified for inclusion in the log, but were not printed because of the rate-limiting, and their respective totals for lock and execution time. This wrapper for prepare_summary() and print_summary() handles the locking/unlocking.
thd | The THD that tries to log the statement. |
false | Logging was not suppressed, no summary needed. |
true | Logging was suppressed; a summary was printed. |
bool Slow_log_throttle::log | ( | THD * | thd, |
bool | eligible | ||
) |
Top-level function.
thd | The THD that tries to log the statement. |
eligible | Is the statement of the type we might suppress? |
true | Logging should be suppressed. |
false | Logging should not be suppressed. |
|
private |
Start a new window.
|
private |
Actually print the prepared summary to log.
|
private |
We're using our own (empty) security context during summary generation.
That way, the aggregate value of the suppressed queries isn't printed with a specific user's name (i.e. the user who sent a query when or after the time-window closes), as that would be misleading.
|
private |
Slow_log_throttle is shared between THDs.
|
private |
The routine we call to actually log a line (our summary).
|
private |
A reference to the threshold ("no more than n log lines per ...").
References a (system-?) variable in the server.
|
private |
Total of the execution times of queries in this time-window for which we suppressed logging.
For use in summary printing.
|
private |
Total of the lock times of queries in this time-window for which we suppressed logging.
For use in summary printing.