MySQL 8.0.39
Source Code Documentation
|
This file contains. More...
Go to the source code of this file.
Classes | |
struct | _log_sink_pfs_event |
Macros | |
#define | LOG_SINK_PFS_ERROR_CODE_LENGTH 10 |
#define | LOG_SINK_PFS_SUBSYS_LENGTH 7 |
Typedefs | |
typedef struct _log_sink_pfs_event | log_sink_pfs_event |
Functions | |
void | log_sink_pfs_read_start () |
Acquire a read-lock on the ring-buffer. More... | |
void | log_sink_pfs_read_end () |
Release read-lock on ring-buffer. More... | |
size_t | log_sink_pfs_event_count () |
Get number of events currently in ring-buffer. More... | |
log_sink_pfs_event * | log_sink_pfs_event_first () |
Get oldest event still in ring-buffer. More... | |
log_sink_pfs_event * | log_sink_pfs_event_next (log_sink_pfs_event *e) |
Get event following the supplied one. More... | |
log_sink_pfs_event * | log_sink_pfs_event_valid (log_sink_pfs_event *e, ulonglong logged) |
Use timestamp to check whether a given event-pointer still points to a valid event in the ring-buffer. More... | |
int | log_error_read_log_init () |
Set up ring-buffer for error-log. More... | |
int | log_error_read_log_exit () |
Release error log ring-buffer. More... | |
log_service_error | log_error_read_log (const char *log_name) |
Restore error log messages from previous shutdown. More... | |
log_service_error | log_sink_pfs_event_add (log_sink_pfs_event *e, const char *blob_src) |
Add a log-event to the ring buffer. More... | |
int | log_sink_perfschema (void *instance, log_line *ll) |
services: log sinks: logging to performance_schema ring-buffer More... | |
Variables | |
ulong | log_sink_pfs_buffered_bytes |
bytes in use (now) More... | |
ulong | log_sink_pfs_buffered_events |
events in buffer (now) More... | |
ulong | log_sink_pfs_expired_events |
number of expired entries (ever) More... | |
ulong | log_sink_pfs_longest_event |
longest event seen (ever) More... | |
ulonglong | log_sink_pfs_latest_timestamp |
timestamp of most recent write More... | |
This file contains.
a) The API for the reading of previously written error logs. (These functions will in turn use a parse-function defined in a log-sink. Whichever log-sink that has a parse-function is listed first in @global.log_error_services will be used; that service will decide what log-file to read (i.e. its name) and how to parse it. We initially support the reading of JSON- formatted error log files and of the traditional MySQL error log files.) This lets us restore error log information from previous runs when the server starts. These functions are called from mysqld.cc at start-up.
b) The log-sink that adds errors logged at run-time to the ring-buffer (to be called from
#define LOG_SINK_PFS_ERROR_CODE_LENGTH 10 |
#define LOG_SINK_PFS_SUBSYS_LENGTH 7 |
typedef struct _log_sink_pfs_event log_sink_pfs_event |
log_service_error log_error_read_log | ( | const char * | log_name | ) |
Restore error log messages from previous shutdown.
We try restoring from the first (leftmost) of those services listed in @global.log_error_services that have the LOG_SERVICE_LOG_PARSER characteristic.
It is assumed that the last run's log file name is the same as the current one's. That is to say, we check whether the file supplied to –log-error already exists.
Once we have determined what file to read from, we'll call
It should be noted that at the point this function is normally called, buffered error logging will not have flushed yet.
a) If we are using the built-in "trad" sink/reader, the start-up messages are usually not buffered, and have already been written to the error log. In this case, they will be restored from the log (and flushing won't add another event to the ring-buffer).
b) If we are using a reader in a loadable log-service,
log_name | The log file to read (log_error_dest). |
LOG_SERVICE_SUCCESS | Success (log read and parsed) |
LOG_SERVICE_UNABLE_TO_READ | Could not read/access() file |
LOG_SERVICE_INVALID_ARGUMENT | Invalid file-name (no '.') |
LOG_SERVICE_NOT_AVAILABLE | No log_component active that can parse log-files |
LOG_SERVICE_ARGUMENT_TOO_LONG | File-name too long |
LOG_SERVICE_COULD_NOT_MAKE_LOG_NAME | Could not determine file extension |
otherwise | Return value from reader |
int log_error_read_log_exit | ( | ) |
Release error log ring-buffer.
0 | Success - buffer was released, or did not exist in the first place. |
int log_error_read_log_init | ( | ) |
Set up ring-buffer for error-log.
0 | Success - buffer was allocated. |
!=0 | Failure - buffer was not allocated. |
int log_sink_perfschema | ( | void * | instance, |
log_line * | ll | ||
) |
services: log sinks: logging to performance_schema ring-buffer
Will write timestamp, label, thread-ID, and message to stderr/file. If you should not be able to specify a label, one will be generated for you from the line's priority field.
instance | instance handle |
ll | the log line to write |
int | number of added fields, if any |
log_service_error log_sink_pfs_event_add | ( | log_sink_pfs_event * | e, |
const char * | blob_src | ||
) |
Add a log-event to the ring buffer.
In the ring-buffer, each event exists as a header and a blob. The header is a log_sink_pfs_event struct containing the traditional error-log columns. It is followed by a variable-length blob that contains just the message string in traditional log mode, and the complete event as JSON in JSON log format. The length of the event will be align to the correct boundary.
If writing the event would go past the end of the ring-buffer, we wrap around to the beginning of the buffer.
After the function success, ring_buffer_read
will be set to a valid, non-zero value.
e | filled-in event struct to copy into the ring-buffer |
blob_src | variable-length part of the event to add to the ring-buffer |
LOG_SERVICE_SUCCESS | event was added |
LOG_SERVICE_NOT_AVAILABLE | ring-buffer not available |
LOG_SERVICE_INVALID_ARGUMENT | event has no message |
LOG_SERVICE_ARGUMENT_TOO_LONG | event is larger than buffer(!) |
size_t log_sink_pfs_event_count | ( | ) |
Get number of events currently in ring-buffer.
Caller should hold THR_LOCK_log_perschema when reading this.
log_sink_pfs_event * log_sink_pfs_event_first | ( | ) |
Get oldest event still in ring-buffer.
Caller should hold read-lock on THR_LOCK_log_perfschema when calling this.
Caller should hold read-lock on THR_LOCK_log_perfschema when calling this.
nullptr | No events in buffer |
otherwise | Address of oldest event in ring-buffer |
log_sink_pfs_event * log_sink_pfs_event_next | ( | log_sink_pfs_event * | e | ) |
Get event following the supplied one.
Caller should hold read-lock on THR_LOCK_log_perfschema when calling this.
If advancing the read position puts the read-pointer beyond the highest-address event in the ring-buffer (which isn't necessarily the latest event, which is defined as the last event before catching up with the write-pointer), i.e. at a position where either a wrap- around marker exists, or there is not enough space for a header, we wrap around to the start of the ring-buffer.
e | Last event the caller was processing. This event should be valid, non-NULL, and should not be a wrap-around marker (m_messages_length == 0). |
nullptr | No more events in ring-buffer (caught up with writer) |
otherwise | Address of the next event in the ring-buffer |
log_sink_pfs_event * log_sink_pfs_event_valid | ( | log_sink_pfs_event * | e, |
ulonglong | logged | ||
) |
Use timestamp to check whether a given event-pointer still points to a valid event in the ring-buffer.
Caller should hold read-lock on THR_LOCK_log_perfschema when calling this.
e | Address of event |
logged | unique timestamp of event |
nullptr | Event no longer exists in ring-buffer |
otherwise | Address of the event in the ring-buffer |
void log_sink_pfs_read_end | ( | ) |
Release read-lock on ring-buffer.
void log_sink_pfs_read_start | ( | ) |
Acquire a read-lock on the ring-buffer.
|
extern |
bytes in use (now)
|
extern |
events in buffer (now)
|
extern |
number of expired entries (ever)
|
extern |
timestamp of most recent write
|
extern |
longest event seen (ever)