23#ifndef BINLOG_INDEX_H_INCLUDED
24#define BINLOG_INDEX_H_INCLUDED
38#define LOG_INFO_EOF -1
40#define LOG_INFO_INVALID -3
41#define LOG_INFO_SEEK -4
42#define LOG_INFO_MEM -6
43#define LOG_INFO_FATAL -7
44#define LOG_INFO_IN_USE -8
45#define LOG_INFO_EMFILE -9
46#define LOG_INFO_BACKUP_LOCK -10
47#define LOG_INFO_NOT_IN_USE -11
234 bool need_update_threads,
357 bool open_index_file(
const char *index_file_name_arg,
const char *log_name,
458 bool need_lock_index);
477 bool need_update_threads,
493 bool need_update_threads,
494 const std::string &
last);
535 bool need_lock_index =
true);
int destroy(azio_stream *s)
Definition: azio.cc:371
bool normalize_binlog_name(char *to, const char *from, bool is_relay_log)
Turns a relative log binary log path into a full path, based on the opt_bin_logname or opt_relay_logn...
Definition: binlog_index.cc:77
int compare_log_name(const char *log_1, const char *log_2)
Compare log file basenames, i.e.
Definition: binlog_index.cc:132
void exec_binlog_error_action_abort(const char *err_string)
When a fatal error occurs due to which binary logging becomes impossible and the user specified binlo...
Definition: binlog_index.cc:139
Binlog_index_monitor synchronizes access to Binlog_index object.
Definition: binlog_index.h:343
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::strin...
Definition: binlog_index.cc:1129
int error_purge_index_file()
Definition: binlog_index.cc:871
int register_create_index_entry(const char *entry)
Definition: binlog_index.cc:877
void lock()
Definition: binlog_index.h:554
void unregister_log_info(Log_info *log_info)
Definition: binlog_index.cc:1063
int reinit_purge_index_file()
Definition: binlog_index.cc:862
int add_log_to_index(uchar *log_name, size_t log_name_len, bool need_lock_index)
Append log file name to index file.
Definition: binlog_index.cc:1067
int find_next_log(Log_info *linfo, bool need_lock_index)
Find the position in the log-index-file for the given log name.
Definition: binlog_index.cc:1116
IO_CACHE * get_index_file()
Definition: binlog_index.h:521
int open_purge_index_file(bool destroy)
Definition: binlog_index.cc:846
int register_purge_index_entry(const char *entry)
Definition: binlog_index.cc:874
int close_purge_index_file()
Definition: binlog_index.cc:849
void cleanup()
Definition: binlog_index.cc:784
bool is_inited_index_file()
Definition: binlog_index.cc:842
const char * get_index_fname() const
Definition: binlog_index.cc:1095
int remove_logs_outside_range_from_index(Log_info *start_log_info, bool need_update_threads, Log_info *last_log_info=nullptr)
Definition: binlog_index.cc:1038
const bool m_is_relay_log
Definition: binlog_index.h:565
int sync_purge_index_file()
Definition: binlog_index.cc:865
Binlog_index & get_index()
Definition: binlog_index.h:551
int gets_purge_index_file(char *to, size_t max_length)
Definition: binlog_index.cc:868
bool is_inited_purge_index_file()
Definition: binlog_index.cc:859
mysql_mutex_t m_LOCK_index
POSIX thread objects are inited by init_pthread_objects()
Definition: binlog_index.h:563
void unlock()
Definition: binlog_index.h:555
void init_pthread_objects()
Definition: binlog_index.cc:780
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.
Definition: binlog_index.cc:1177
int purge_index_entry(THD *thd, ulonglong *decrease_log_space, PSI_file_key key_file_log, bool need_lock_index)
Definition: binlog_index.cc:881
int end_close_purge_index_file()
Definition: binlog_index.cc:852
int set_purge_index_file_name(const char *base_file_name)
Definition: binlog_index.cc:855
void adjust_linfo_offsets(my_off_t purge_offset)
Definition: binlog_index.cc:1090
void assert_owner()
Definition: binlog_index.h:556
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.
Definition: binlog_index.cc:1099
int log_in_use(const char *log_name)
Check if any threads use log name.
Definition: binlog_index.cc:1085
mysql_mutex_t * get_index_lock()
Definition: binlog_index.h:553
void register_log_info(Log_info *log_info)
Definition: binlog_index.cc:1060
Binlog_index m_binlog_index
Definition: binlog_index.h:564
PSI_mutex_key m_key_LOCK_index
The instrumentation key to use for @ LOCK_index.
Definition: binlog_index.h:560
Binlog_index_monitor(bool relay_log)
Definition: binlog_index.cc:770
bool open_index_file(const char *index_file_name_arg, const char *log_name, PSI_file_key key_file_log, bool need_lock_index)
Definition: binlog_index.cc:786
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)
Definition: binlog_index.cc:773
int move_crash_safe_index_file_to_index_file(bool need_lock_index)
Move crash safe index file to index file.
Definition: binlog_index.cc:1024
std::pair< std::list< std::string >, mysql::utils::Error > get_filename_list()
Obtains the list of logs from the index file.
Definition: binlog_index.cc:1153
int close_index_file(bool need_lock_index)
Definition: binlog_index.cc:829
Binlog_index defines methods which handle binlog index file and its entries.
Definition: binlog_index.h:102
int end_close_purge_index_file()
simulate failure using fault_injection_registering_index debug symbol
Definition: binlog_index.cc:354
int log_in_use(const char *log_name)
Return number of logs in use.
Definition: binlog_index.cc:736
int open_crash_safe_index_file()
Open a (new) crash safe index file.
Definition: binlog_index.cc:264
bool is_inited_index_file()
Check if index file is initalized.
Definition: binlog_index.cc:262
int set_crash_safe_index_file_name(const char *base_file_name)
Set the name of crash safe index file.
Definition: binlog_index.cc:299
IO_CACHE index_file
Definition: binlog_index.h:308
char crash_safe_index_file_name[FN_REFLEN]
Definition: binlog_index.h:315
Binlog_index(bool relay_log)
Definition: binlog_index.cc:185
int open_purge_index_file(bool destroy)
Functions to manage purge index file.
Definition: binlog_index.cc:316
int set_purge_index_file_name(const char *base_file_name)
Definition: binlog_index.cc:367
int close_purge_index_file()
Definition: binlog_index.cc:339
int reinit_purge_index_file()
Definition: binlog_index.cc:383
int close_index_file()
Close index file.
Definition: binlog_index.cc:251
void set_psi_keys(PSI_file_key key_file_log_index, PSI_file_key key_file_log_index_cache)
Definition: binlog_index.cc:189
int 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'.
Definition: binlog_index.cc:684
char purge_index_file_name[FN_REFLEN]
Definition: binlog_index.h:323
PSI_file_key m_key_file_log_index
The instrumentation key to use for opening the log index file.
Definition: binlog_index.h:304
void unregister_log_info(Log_info *log_info)
Unregister log_info.
Definition: binlog_index.cc:731
int close_crash_safe_index_file()
Close the crash safe index file.
Definition: binlog_index.cc:285
void adjust_linfo_offsets(my_off_t purge_offset)
Adjust all registered log_infos by purge_offset.
Definition: binlog_index.cc:754
char index_file_name[FN_REFLEN]
Definition: binlog_index.h:309
int register_create_index_entry(const char *entry)
Definition: binlog_index.cc:416
int add_log_to_index(uchar *log_name, size_t log_name_len)
Append log file name to index file.
Definition: binlog_index.cc:511
IO_CACHE purge_index_file
purge_file is a temp file used in purge_logs so that the index file can be updated before deleting fi...
Definition: binlog_index.h:322
int sync_purge_index_file()
Definition: binlog_index.cc:387
int gets_purge_index_file(char *to, size_t max_length)
Read purge index file name into to buffer of max_length.
Definition: binlog_index.cc:398
IO_CACHE * get_index_file()
Definition: binlog_index.h:266
void register_log_info(Log_info *log_info)
Register log_info which is used by log_in_use and adjust_linfo_offsets functions.
Definition: binlog_index.cc:726
bool is_inited_crash_safe_index_file()
Check if crash safe index is initalized.
Definition: binlog_index.cc:312
const char * get_index_fname() const
Definition: binlog_index.h:265
int find_next_log(Log_info *linfo)
Find the position in the log-index-file for the given log name.
Definition: binlog_index.cc:478
const bool is_relay_log
Definition: binlog_index.h:325
int find_log_pos(Log_info *linfo, const char *log_name)
Find the position in the log-index-file for the given log name.
Definition: binlog_index.cc:420
int error_purge_index_file()
Definition: binlog_index.cc:402
IO_CACHE crash_safe_index_file
crash_safe_index_file is temp file used for guaranteeing index file crash safe when master server res...
Definition: binlog_index.h:314
int move_crash_safe_index_file_to_index_file()
Move crash safe index file to index file.
Definition: binlog_index.cc:546
static const int MAX_RETRIES_FOR_DELETE_RENAME_FAILURE
Definition: binlog_index.h:332
bool open_index_file(const char *index_file_name_arg, myf opt)
Create an index file that will hold all file names used for logging.
Definition: binlog_index.cc:195
int register_purge_index_entry(const char *entry)
Definition: binlog_index.cc:404
PSI_file_key m_key_file_log_index_cache
The instrumentation key to use for opening a log index cache file.
Definition: binlog_index.h:306
std::set< Log_info * > log_info_set
Set of log info objects that are in usage and might prevent some other operations from executing.
Definition: binlog_index.h:330
bool is_inited_purge_index_file()
Definition: binlog_index.cc:379
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:36
Error representation used internally in case final error code is unknown and error situation handling...
Definition: error.h:45
#define mysql_mutex_lock(M)
Definition: mysql_mutex.h:50
#define mysql_mutex_unlock(M)
Definition: mysql_mutex.h:57
#define log_info(...)
Definition: log_client.h:153
unsigned int PSI_file_key
Instrumented file key.
Definition: psi_file_bits.h:48
unsigned int PSI_mutex_key
Instrumented mutex key.
Definition: psi_mutex_bits.h:52
#define mysql_mutex_assert_owner(M)
Wrapper, to use safe_mutex_assert_owner with instrumented mutexes.
Definition: mysql_mutex.h:112
Some integer typedefs for easier portability.
int myf
Definition: my_inttypes.h:94
unsigned long long int ulonglong
Definition: my_inttypes.h:56
ulonglong my_off_t
Definition: my_inttypes.h:72
unsigned char uchar
Definition: my_inttypes.h:52
Common #defines and includes for file and socket I/O.
#define FN_REFLEN
Definition: my_io.h:83
Common header for many mysys elements.
uint32 my_thread_id
Definition: my_thread_local.h:34
Performance schema instrumentation interface.
Definition: binlog_index.h:86
bool fatal
Definition: binlog_index.h:92
my_off_t index_file_offset
Definition: binlog_index.h:90
Log_info()
Definition: binlog_index.cc:174
char log_file_name[FN_REFLEN]
Definition: binlog_index.h:89
my_thread_id thread_id
Definition: binlog_index.h:95
my_off_t index_file_start_offset
Definition: binlog_index.h:90
int entry_index
Definition: binlog_index.h:93
my_off_t pos
Definition: binlog_index.h:91
int encrypted_header_size
Definition: binlog_index.h:94
Definition: completion_hash.h:35
An instrumented mutex structure.
Definition: mysql_mutex_bits.h:50