Binlog_index defines methods which handle binlog index file and its entries.
More...
#include <binlog_index.h>
Binlog_index defines methods which handle binlog index file and its entries.
- See also
- Binlog_index_monitor to synchronize access to Binlog_index object.
◆ Binlog_index()
Binlog_index::Binlog_index |
( |
bool |
relay_log | ) |
|
◆ add_log_to_index()
int Binlog_index::add_log_to_index |
( |
uchar * |
log_name, |
|
|
size_t |
log_name_len |
|
) |
| |
Append log file name to index file.
- To make crash safe, we copy all the content of index file to crash safe index file firstly and then append the log file name to the crash safe index file. Finally move the crash safe index file to index file.
- Parameters
-
log_name | Log file name |
log_name_len | Length of log file name |
- Return values
-
◆ adjust_linfo_offsets()
void Binlog_index::adjust_linfo_offsets |
( |
my_off_t |
purge_offset | ) |
|
Adjust all registered log_infos by purge_offset.
- Parameters
-
purge_offset | offset by which log_info are offset |
◆ close_crash_safe_index_file()
int Binlog_index::close_crash_safe_index_file |
( |
| ) |
|
|
private |
Close the crash safe index file.
- Note
- The crash safe file is just closed, is not deleted. Because it is moved to index file later on.
- Return values
-
◆ close_index_file()
int Binlog_index::close_index_file |
( |
| ) |
|
Close index file.
- Returns
- 0 - success, !0 - failure
◆ close_purge_index_file()
int Binlog_index::close_purge_index_file |
( |
| ) |
|
◆ end_close_purge_index_file()
int Binlog_index::end_close_purge_index_file |
( |
| ) |
|
simulate failure using fault_injection_registering_index debug symbol
◆ error_purge_index_file()
int Binlog_index::error_purge_index_file |
( |
| ) |
|
◆ find_log_pos()
int Binlog_index::find_log_pos |
( |
Log_info * |
linfo, |
|
|
const char * |
log_name |
|
) |
| |
Find the position in the log-index-file for the given log name.
- Parameters
-
[out] | linfo | The found log file name will be stored here, along with the byte offset of the next log file name in the index file. |
| log_name | Filename to find in the index file, or NULL if we want to read the first entry. |
- Note
- On systems without the truncate function the file will end with one or more empty lines. These will be ignored when reading the file.
- Return values
-
0 | ok |
LOG_INFO_EOF | End of log-index-file found |
LOG_INFO_IO | Got IO error while reading file |
◆ find_next_log()
int Binlog_index::find_next_log |
( |
Log_info * |
linfo | ) |
|
Find the position in the log-index-file for the given log name.
- Parameters
-
[out] | linfo | The filename will be stored here, along with the byte offset of the next filename in the index file. |
- Note
- Before calling this function, one has to call find_log_pos() to set up 'linfo'
- Return values
-
0 | ok |
LOG_INFO_EOF | End of log-index-file found |
LOG_INFO_IO | Got IO error while reading file |
◆ get_index_file()
IO_CACHE * Binlog_index::get_index_file |
( |
| ) |
|
|
inline |
◆ get_index_fname()
const char * Binlog_index::get_index_fname |
( |
| ) |
const |
|
inline |
◆ gets_purge_index_file()
int Binlog_index::gets_purge_index_file |
( |
char * |
to, |
|
|
size_t |
max_length |
|
) |
| |
Read purge index file name into to buffer of max_length.
- Parameters
-
to | buffer where to store purge index file name |
max_length | length of the to buffer |
- Returns
- number of characters read, 0 on error
◆ is_inited_crash_safe_index_file()
bool Binlog_index::is_inited_crash_safe_index_file |
( |
| ) |
|
|
private |
Check if crash safe index is initalized.
- Returns
- true - is initalized, false - otherwise
◆ is_inited_index_file()
bool Binlog_index::is_inited_index_file |
( |
| ) |
|
Check if index file is initalized.
- Returns
- true - initalized, false - otherwise
◆ is_inited_purge_index_file()
bool Binlog_index::is_inited_purge_index_file |
( |
| ) |
|
◆ log_in_use()
int Binlog_index::log_in_use |
( |
const char * |
log_name | ) |
|
Return number of logs in use.
- Parameters
-
log_name | log_name to be searched among files registered by register_log_info |
- Returns
- number of logs in use
◆ move_crash_safe_index_file_to_index_file()
int Binlog_index::move_crash_safe_index_file_to_index_file |
( |
| ) |
|
Move crash safe index file to index file.
- Return values
-
◆ open_crash_safe_index_file()
int Binlog_index::open_crash_safe_index_file |
( |
| ) |
|
|
private |
Open a (new) crash safe index file.
- Note
- The crash safe index file is a special file used for guaranteeing index file crash safe.
- Return values
-
◆ open_index_file()
bool Binlog_index::open_index_file |
( |
const char * |
index_file_name_arg, |
|
|
myf |
opt |
|
) |
| |
Create an index file that will hold all file names used for logging.
- Parameters
-
index_file_name_arg | name of the index file |
opt | opening mode |
- Returns
- false - success, true - failure
◆ open_purge_index_file()
int Binlog_index::open_purge_index_file |
( |
bool |
destroy | ) |
|
Functions to manage purge index file.
- See also
- purge_index_file
◆ register_create_index_entry()
int Binlog_index::register_create_index_entry |
( |
const char * |
entry | ) |
|
◆ register_log_info()
void Binlog_index::register_log_info |
( |
Log_info * |
log_info | ) |
|
Register log_info which is used by log_in_use and adjust_linfo_offsets functions.
- Parameters
-
log_info | - log_info to be registered |
◆ register_purge_index_entry()
int Binlog_index::register_purge_index_entry |
( |
const char * |
entry | ) |
|
◆ reinit_purge_index_file()
int Binlog_index::reinit_purge_index_file |
( |
| ) |
|
◆ remove_logs_outside_range_from_index()
int Binlog_index::remove_logs_outside_range_from_index |
( |
Log_info * |
start_log_info, |
|
|
bool |
need_update_threads, |
|
|
Log_info * |
last_log_info = nullptr |
|
) |
| |
Remove logs from index file, except files between 'start' and 'last'.
To make it crash safe, we copy the content of the index file from index_file_start_offset recorded in log_info to a crash safe index file first and then move the crash safe index file to the index file.
- Parameters
-
start_log_info | Metadata of the first log to be kept in the index file. |
need_update_threads | If we want to update the log coordinates of all threads. False for relay logs, true otherwise. |
last_log_info | Metadata of the last log to be kept in the index file; nullptr means that all logs after start_log_info will be kept |
- Return values
-
0 | ok |
LOG_INFO_IO | Got IO error while reading/writing file |
◆ set_crash_safe_index_file_name()
int Binlog_index::set_crash_safe_index_file_name |
( |
const char * |
base_file_name | ) |
|
|
private |
Set the name of crash safe index file.
- Return values
-
◆ set_psi_keys()
◆ set_purge_index_file_name()
int Binlog_index::set_purge_index_file_name |
( |
const char * |
base_file_name | ) |
|
◆ sync_purge_index_file()
int Binlog_index::sync_purge_index_file |
( |
| ) |
|
◆ unregister_log_info()
void Binlog_index::unregister_log_info |
( |
Log_info * |
log_info | ) |
|
Unregister log_info.
- Parameters
-
log_info | - log_info to be unregistered |
- See also
- register_log_info
◆ crash_safe_index_file
IO_CACHE Binlog_index::crash_safe_index_file |
|
private |
crash_safe_index_file is temp file used for guaranteeing index file crash safe when master server restarts.
◆ crash_safe_index_file_name
char Binlog_index::crash_safe_index_file_name[FN_REFLEN] |
|
private |
◆ index_file
◆ index_file_name
char Binlog_index::index_file_name[FN_REFLEN] |
|
private |
◆ is_relay_log
const bool Binlog_index::is_relay_log |
|
private |
◆ log_info_set
std::set<Log_info *> Binlog_index::log_info_set |
|
private |
Set of log info objects that are in usage and might prevent some other operations from executing.
◆ m_key_file_log_index
The instrumentation key to use for opening the log index file.
◆ m_key_file_log_index_cache
The instrumentation key to use for opening a log index cache file.
◆ MAX_RETRIES_FOR_DELETE_RENAME_FAILURE
const int Binlog_index::MAX_RETRIES_FOR_DELETE_RENAME_FAILURE = 5 |
|
staticprivate |
◆ purge_index_file
purge_file is a temp file used in purge_logs so that the index file can be updated before deleting files from disk, yielding better crash recovery.
It is created on demand the first time purge_logs is called and then reused for subsequent calls. It is cleaned up in cleanup().
◆ purge_index_file_name
char Binlog_index::purge_index_file_name[FN_REFLEN] |
|
private |
The documentation for this class was generated from the following files: