MySQL 9.1.0
Source Code Documentation
|
Binlog_index_monitor synchronizes access to Binlog_index object. More...
#include <binlog_index.h>
Public Member Functions | |
Binlog_index_monitor (bool relay_log) | |
void | set_psi_keys (PSI_mutex_key key_LOCK_index, PSI_file_key key_file_log_index, PSI_file_key key_file_log_index_cache) |
void | init_pthread_objects () |
void | cleanup () |
bool | open_index_file (const char *index_file_name_arg, const char *log_name, PSI_file_key key_file_log, bool need_lock_index) |
int | close_index_file (bool need_lock_index) |
bool | is_inited_index_file () |
int | open_purge_index_file (bool destroy) |
int | close_purge_index_file () |
int | end_close_purge_index_file () |
int | set_purge_index_file_name (const char *base_file_name) |
bool | is_inited_purge_index_file () |
int | reinit_purge_index_file () |
int | sync_purge_index_file () |
int | gets_purge_index_file (char *to, size_t max_length) |
int | error_purge_index_file () |
int | register_purge_index_entry (const char *entry) |
int | register_create_index_entry (const char *entry) |
int | purge_index_entry (THD *thd, ulonglong *decrease_log_space, PSI_file_key key_file_log, bool need_lock_index) |
int | find_log_pos (Log_info *linfo, const char *log_name, bool need_lock_index) |
Find the position in the log-index-file for the given log name. More... | |
int | find_next_log (Log_info *linfo, bool need_lock_index) |
Find the position in the log-index-file for the given log name. More... | |
int | add_log_to_index (uchar *log_name, size_t log_name_len, bool need_lock_index) |
Append log file name to index file. More... | |
int | move_crash_safe_index_file_to_index_file (bool need_lock_index) |
Move crash safe index file to index file. More... | |
int | remove_logs_outside_range_from_index (Log_info *start_log_info, bool need_update_threads, Log_info *last_log_info=nullptr) |
int | remove_logs_outside_range_from_index (const std::string &first, bool need_update_threads, const std::string &last) |
Remove logs from index file except logs between first and last. More... | |
void | register_log_info (Log_info *log_info) |
void | unregister_log_info (Log_info *log_info) |
int | log_in_use (const char *log_name) |
Check if any threads use log name. More... | |
void | adjust_linfo_offsets (my_off_t purge_offset) |
const char * | get_index_fname () const |
IO_CACHE * | get_index_file () |
std::pair< int, std::list< std::string > > | get_log_index (bool need_lock_index=true) |
Retrieves the contents of the index file associated with this log object into an std::list<std::string> object. More... | |
std::pair< std::list< std::string >, mysql::utils::Error > | get_filename_list () |
Obtains the list of logs from the index file. More... | |
int | find_next_relay_log (char log_name[FN_REFLEN+1]) |
Find the relay log name following the given name from relay log index file. More... | |
Binlog_index & | get_index () |
mysql_mutex_t * | get_index_lock () |
void | lock () |
void | unlock () |
void | assert_owner () |
Private Attributes | |
PSI_mutex_key | m_key_LOCK_index |
The instrumentation key to use for @ LOCK_index. More... | |
mysql_mutex_t | m_LOCK_index |
POSIX thread objects are inited by init_pthread_objects() More... | |
Binlog_index | m_binlog_index |
const bool | m_is_relay_log |
Binlog_index_monitor synchronizes access to Binlog_index object.
Methods defined by Binlog_index are exposed through Binlog_index_monitor class.
Please keep in mind that LOCK_index is exposed and its lock and unlock methods need to be called with caution.
Binlog_index_monitor::Binlog_index_monitor | ( | bool | relay_log | ) |
int Binlog_index_monitor::add_log_to_index | ( | uchar * | log_name, |
size_t | log_name_len, | ||
bool | need_lock_index | ||
) |
Append log file name to index file.
log_name | Log file name |
log_name_len | Length of log file name |
need_lock_index | If true, LOCK_index will be acquired; otherwise it should already be held by the caller. |
0 | ok |
-1 | error |
void Binlog_index_monitor::adjust_linfo_offsets | ( | my_off_t | purge_offset | ) |
|
inline |
void Binlog_index_monitor::cleanup | ( | ) |
int Binlog_index_monitor::close_index_file | ( | bool | need_lock_index | ) |
int Binlog_index_monitor::close_purge_index_file | ( | ) |
int Binlog_index_monitor::end_close_purge_index_file | ( | ) |
int Binlog_index_monitor::error_purge_index_file | ( | ) |
int Binlog_index_monitor::find_log_pos | ( | Log_info * | linfo, |
const char * | log_name, | ||
bool | need_lock_index | ||
) |
Find the position in the log-index-file for the given log name.
[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. | |
need_lock_index | If false, this function acquires LOCK_index; otherwise the lock should already be held by the caller. |
0 | ok |
LOG_INFO_EOF | End of log-index-file found |
LOG_INFO_IO | Got IO error while reading file |
int Binlog_index_monitor::find_next_log | ( | Log_info * | linfo, |
bool | need_lock_index | ||
) |
Find the position in the log-index-file for the given log name.
[out] | linfo | The filename will be stored here, along with the byte offset of the next filename in the index file. |
need_lock_index | If true, LOCK_index will be acquired; otherwise it should already be held by the caller. |
0 | ok |
LOG_INFO_EOF | End of log-index-file found |
LOG_INFO_IO | Got IO error while reading file |
int Binlog_index_monitor::find_next_relay_log | ( | char | log_name[FN_REFLEN+1] | ) |
Find the relay log name following the given name from relay log index file.
[in,out] | log_name | The name is full path name. |
std::pair< std::list< std::string >, mysql::utils::Error > Binlog_index_monitor::get_filename_list | ( | ) |
Obtains the list of logs from the index file.
|
inline |
|
inline |
const char * Binlog_index_monitor::get_index_fname | ( | ) | const |
|
inline |
std::pair< int, std::list< std::string > > Binlog_index_monitor::get_log_index | ( | bool | need_lock_index = true | ) |
Retrieves the contents of the index file associated with this log object into an std::list<std::string>
object.
The order held by the index file is kept.
need_lock_index | whether or not the lock over the index file should be acquired inside the function. |
std::string
objects with the content of the log index file. int Binlog_index_monitor::gets_purge_index_file | ( | char * | to, |
size_t | max_length | ||
) |
void Binlog_index_monitor::init_pthread_objects | ( | ) |
bool Binlog_index_monitor::is_inited_index_file | ( | ) |
bool Binlog_index_monitor::is_inited_purge_index_file | ( | ) |
|
inline |
int Binlog_index_monitor::log_in_use | ( | const char * | log_name | ) |
Check if any threads use log name.
log_name | name of a log which is checked for usage |
int Binlog_index_monitor::move_crash_safe_index_file_to_index_file | ( | bool | need_lock_index | ) |
Move crash safe index file to index file.
need_lock_index | If true, LOCK_index will be acquired; otherwise it should already be held. |
0 | ok |
-1 | error |
bool Binlog_index_monitor::open_index_file | ( | const char * | index_file_name_arg, |
const char * | log_name, | ||
PSI_file_key | key_file_log, | ||
bool | need_lock_index | ||
) |
int Binlog_index_monitor::open_purge_index_file | ( | bool | destroy | ) |
int Binlog_index_monitor::purge_index_entry | ( | THD * | thd, |
ulonglong * | decrease_log_space, | ||
PSI_file_key | key_file_log, | ||
bool | need_lock_index | ||
) |
int Binlog_index_monitor::register_create_index_entry | ( | const char * | entry | ) |
void Binlog_index_monitor::register_log_info | ( | Log_info * | log_info | ) |
int Binlog_index_monitor::register_purge_index_entry | ( | const char * | entry | ) |
int Binlog_index_monitor::reinit_purge_index_file | ( | ) |
int Binlog_index_monitor::remove_logs_outside_range_from_index | ( | const std::string & | first, |
bool | need_update_threads, | ||
const std::string & | last | ||
) |
Remove logs from index file except logs between first and last.
first | Filename of the first relay log to be kept in index file |
need_update_threads | If we want to update the log coordinates of all threads. False for relay logs, true otherwise |
last | Filename of the last relay log to be kept in index file |
0 | OK |
LOG_INFO_IO | Got IO error while reading/writing file |
LOG_INFO_EOF | Could not find requested log file (first or last) |
int Binlog_index_monitor::remove_logs_outside_range_from_index | ( | Log_info * | start_log_info, |
bool | need_update_threads, | ||
Log_info * | last_log_info = nullptr |
||
) |
void Binlog_index_monitor::set_psi_keys | ( | PSI_mutex_key | key_LOCK_index, |
PSI_file_key | key_file_log_index, | ||
PSI_file_key | key_file_log_index_cache | ||
) |
int Binlog_index_monitor::set_purge_index_file_name | ( | const char * | base_file_name | ) |
int Binlog_index_monitor::sync_purge_index_file | ( | ) |
|
inline |
void Binlog_index_monitor::unregister_log_info | ( | Log_info * | log_info | ) |
|
private |
|
private |
|
private |
The instrumentation key to use for @ LOCK_index.
|
private |
POSIX thread objects are inited by init_pthread_objects()