MySQL 5.6.14 Source Code Document
|
Classes | |
class | Mutex_sentry |
class | Thread_excursion |
class | binlog_cache_data |
class | binlog_stmt_cache_data |
class | binlog_trx_cache_data |
class | binlog_cache_mngr |
class | Row_data_memory |
Macros | |
#define | MY_OFF_T_UNDEF (~(my_off_t)0UL) |
#define | LIMIT_UNSAFE_WARNING_ACTIVATION_TIMEOUT 50 |
#define | LIMIT_UNSAFE_WARNING_ACTIVATION_THRESHOLD_COUNT 50 |
#define | MAX_SESSION_ATTACH_TRIES 10 |
Enumerations | |
enum | enum_read_gtids_from_binlog_status { GOT_GTIDS, GOT_PREVIOUS_GTIDS, NO_GTIDS, ERROR, TRUNCATED } |
Functions | |
void | check_binlog_cache_size (THD *thd) |
void | check_binlog_stmt_cache_size (THD *thd) |
bool | binlog_enabled () |
int | gtid_empty_group_log_and_cleanup (THD *thd) |
int | check_binlog_magic (IO_CACHE *log, const char **errmsg) |
File | open_binlog_file (IO_CACHE *log, const char *log_file_name, const char **errmsg) |
bool | trans_has_updated_trans_table (const THD *thd) |
bool | stmt_has_updated_trans_table (const THD *thd) |
bool | ending_trans (THD *thd, const bool all) |
bool | ending_single_stmt_trans (THD *thd, const bool all) |
bool | trans_cannot_safely_rollback (const THD *thd) |
bool | stmt_cannot_safely_rollback (const THD *thd) |
bool | purge_master_logs (THD *thd, const char *to_log) |
bool | purge_master_logs_before_date (THD *thd, time_t purge_time) |
int | query_error_code (THD *thd, bool not_killed) |
void | register_binlog_handler (THD *thd, bool trx) |
int | binlog_stmt_cache_data::finalize (THD *thd) |
int | binlog_cache_data::write_event (THD *thd, Log_event *event) |
int | binlog_cache_data::finalize (THD *thd, Log_event *end_event) |
int | binlog_cache_data::flush (THD *thd, my_off_t *bytes, bool *wrote_xid) |
int | binlog_trx_cache_data::truncate (THD *thd, bool all) |
bool | Stage_manager::Mutex_queue::append (THD *first) |
std::pair< bool, THD * > | Stage_manager::Mutex_queue::pop_front () |
bool | Stage_manager::enroll_for (StageID stage, THD *first, mysql_mutex_t *stage_mutex) |
THD * | Stage_manager::Mutex_queue::fetch_and_empty () |
void | Stage_manager::clear_preempt_status (THD *head) |
int | MYSQL_BIN_LOG::rollback (THD *thd, bool all) |
MYSQL_BIN_LOG::MYSQL_BIN_LOG (uint *sync_period) | |
void | MYSQL_BIN_LOG::cleanup () |
void | MYSQL_BIN_LOG::init_pthread_objects () |
bool | MYSQL_BIN_LOG::open_index_file (const char *index_file_name_arg, const char *log_name, bool need_lock_index) |
bool | MYSQL_BIN_LOG::find_first_log_not_in_gtid_set (char *binlog_file_name, const Gtid_set *gtid_set, const char **errmsg) |
bool | MYSQL_BIN_LOG::init_gtid_sets (Gtid_set *gtid_set, Gtid_set *lost_groups, bool verify_checksum, bool need_lock) |
bool | MYSQL_BIN_LOG::open_binlog (const char *log_name, const char *new_name, enum cache_type io_cache_type_arg, ulong max_size, bool null_created, bool need_lock_index, bool need_sid_lock, Format_description_log_event *extra_description_event) |
int | MYSQL_BIN_LOG::move_crash_safe_index_file_to_index_file (bool need_lock_index) |
int | MYSQL_BIN_LOG::add_log_to_index (uchar *log_file_name, int name_len, bool need_lock_index) |
int | MYSQL_BIN_LOG::get_current_log (LOG_INFO *linfo) |
int | MYSQL_BIN_LOG::raw_get_current_log (LOG_INFO *linfo) |
bool | MYSQL_BIN_LOG::check_write_error (THD *thd) |
void | MYSQL_BIN_LOG::set_write_error (THD *thd, bool is_transactional) |
int | MYSQL_BIN_LOG::find_log_pos (LOG_INFO *linfo, const char *log_name, bool need_lock_index) |
int | MYSQL_BIN_LOG::find_next_log (LOG_INFO *linfo, bool need_lock_index) |
bool | MYSQL_BIN_LOG::reset_logs (THD *thd) |
int | MYSQL_BIN_LOG::set_crash_safe_index_file_name (const char *base_file_name) |
int | MYSQL_BIN_LOG::open_crash_safe_index_file () |
int | MYSQL_BIN_LOG::close_crash_safe_index_file () |
void | MYSQL_BIN_LOG::make_log_name (char *buf, const char *log_ident) |
bool | MYSQL_BIN_LOG::is_active (const char *log_file_name) |
int | MYSQL_BIN_LOG::new_file (Format_description_log_event *extra_description_event) |
bool | MYSQL_BIN_LOG::flush_and_sync (const bool force=false) |
void | MYSQL_BIN_LOG::start_union_events (THD *thd, query_id_t query_id_param) |
void | MYSQL_BIN_LOG::stop_union_events (THD *thd) |
bool | MYSQL_BIN_LOG::is_query_in_union (THD *thd, query_id_t query_id_param) |
void | MYSQL_BIN_LOG::update_thd_next_event_pos (THD *thd) |
int | MYSQL_BIN_LOG::flush_and_set_pending_rows_event (THD *thd, Rows_log_event *event, bool is_transactional) |
bool | MYSQL_BIN_LOG::write_event (Log_event *event_info) |
int | MYSQL_BIN_LOG::rotate (bool force_rotate, bool *check_purge) |
void | MYSQL_BIN_LOG::purge () |
int | MYSQL_BIN_LOG::rotate_and_purge (bool force_rotate) |
uint | MYSQL_BIN_LOG::next_file_id () |
int | MYSQL_BIN_LOG::do_write_cache (IO_CACHE *cache) |
bool | MYSQL_BIN_LOG::write_incident (Incident_log_event *ev, bool need_lock_log, bool do_flush_and_sync=true) |
bool | MYSQL_BIN_LOG::write_incident (THD *thd, bool need_lock_log, bool do_flush_and_sync=true) |
bool | MYSQL_BIN_LOG::write_cache (THD *thd, class binlog_cache_data *binlog_cache_data) |
int | MYSQL_BIN_LOG::wait_for_update_relay_log (THD *thd, const struct timespec *timeout) |
int | MYSQL_BIN_LOG::wait_for_update_bin_log (THD *thd, const struct timespec *timeout) |
void | MYSQL_BIN_LOG::close (uint exiting) |
void | MYSQL_BIN_LOG::set_max_size (ulong max_size_arg) |
void | MYSQL_BIN_LOG::signal_update () |
int | MYSQL_BIN_LOG::open_binlog (const char *opt_name) |
void | MYSQL_BIN_LOG::close () |
int | MYSQL_BIN_LOG::prepare (THD *thd, bool all) |
enum_result | MYSQL_BIN_LOG::commit (THD *thd, bool all) |
int | MYSQL_BIN_LOG::recover (IO_CACHE *log, Format_description_log_event *fdle, my_off_t *valid_pos) |
Variables | |
bool | opt_binlog_order_commits = true |
const char * | log_bin_index = 0 |
const char * | log_bin_basename = 0 |
MYSQL_BIN_LOG mysql_bin_log & | sync_binlog_period |
struct st_mysql_storage_engine | binlog_storage_engine |
Reads GTIDs from the given binlog file.
filename | File to read from. |
all_gtids | If not NULL, then the GTIDs from the Previous_gtids_log_event and from all Gtid_log_events are stored in this object. |
prev_gtids | If not NULL, then the GTIDs from the Previous_gtids_log_events are stored in this object. |
verify_checksum | Set to true to verify event checksums. |
GOT_GTIDS | The file was successfully read and it contains both Gtid_log_events and Previous_gtids_log_events. |
GOT_PREVIOUS_GTIDS | The file was successfully read and it contains Previous_gtids_log_events but no Gtid_log_events. |
NO_GTIDS | The file was successfully read and it does not contain GTID events. |
ERROR | Out of memory, or the file contains GTID events when GTID_MODE = OFF, or the file is malformed (e.g., contains Gtid_log_events but no Previous_gtids_log_event). |
TRUNCATED | The file was truncated before the end of the first Previous_gtids_log_event. |
int MYSQL_BIN_LOG::add_log_to_index | ( | uchar * | log_name, |
int | log_name_len, | ||
bool | need_lock_index | ||
) |
Append log file name to index file.
0 | ok |
-1 | error |
Definition at line 3271 of file binlog.cc.
bool Stage_manager::Mutex_queue::append | ( | THD * | first | ) |
bool binlog_enabled | ( | ) |
void check_binlog_cache_size | ( | THD * | thd | ) |
void check_binlog_stmt_cache_size | ( | THD * | thd | ) |
void Stage_manager::clear_preempt_status | ( | THD * | head | ) |
void MYSQL_BIN_LOG::close | ( | ) |
void MYSQL_BIN_LOG::close | ( | uint | exiting | ) |
Close the log file.
exiting | Bitmask for one or more of the following bits:
|
Definition at line 5840 of file binlog.cc.
int MYSQL_BIN_LOG::close_crash_safe_index_file | ( | ) |
TC_LOG::enum_result MYSQL_BIN_LOG::commit | ( | THD * | thd, |
bool | all | ||
) |
Commit the transaction in the transaction coordinator.
This function will commit the sessions transaction in the binary log and in the storage engines (by calling ha_commit_low
). If the transaction was successfully logged (or not successfully unlogged) but the commit in the engines did not succed, there is a risk of inconsistency between the engines and the binary log.
For binary log group commit, the commit is separated into three parts:
0 | success |
1 | error, transaction was neither logged nor committed |
2 | error, transaction was logged but not committed |
Definition at line 6133 of file binlog.cc.
bool ending_single_stmt_trans | ( | THD * | thd, |
const bool | all | ||
) |
This function checks if a single statement transaction is about to commit or not.
thd | The client thread that executed the current statement. |
all | Committing a transaction (i.e. TRUE) or a statement (i.e. FALSE). |
true
if committing a single statement transaction, otherwise false
. Definition at line 1979 of file binlog.cc.
bool ending_trans | ( | THD * | thd, |
const bool | all | ||
) |
This function checks if a transaction, either a multi-statement or a single statement transaction is about to commit or not.
thd | The client thread that executed the current statement. |
all | Committing a transaction (i.e. TRUE) or a statement (i.e. FALSE). |
true
if committing a transaction, otherwise false
. Definition at line 1963 of file binlog.cc.
bool Stage_manager::enroll_for | ( | StageID | stage, |
THD * | first, | ||
mysql_mutex_t * | stage_mutex | ||
) |
Enroll a set of sessions for a stage.
This will queue the session thread for writing and flushing.
If the thread being queued is assigned as stage leader, it will return immediately.
If wait_if_follower is true the thread is not the stage leader, the thread will be wait for the queue to be processed by the leader before it returns. In DBUG-ON version the follower marks is preempt status as ready.
stage | Stage identifier for the queue to append to. |
first | Queue to append. |
stage_mutex | Pointer to the currently held stage mutex, or NULL if we're not in a stage. |
true | Thread is stage leader. |
false | Thread was not stage leader and processing has been done. |
Definition at line 1413 of file binlog.cc.
THD * Stage_manager::Mutex_queue::fetch_and_empty | ( | ) |
int binlog_cache_data::finalize | ( | THD * | thd, |
Log_event * | end_event | ||
) |
This function finalizes the cache preparing for commit or rollback.
The function just writes all the necessary events to the cache but does not flush the data to the binary log file. That is the role of the binlog_cache_data::flush function.
thd | The thread whose transaction should be flushed |
cache_data | Pointer to the cache |
end_ev | The end event either commit/rollback |
Definition at line 1143 of file binlog.cc.
bool MYSQL_BIN_LOG::find_first_log_not_in_gtid_set | ( | char * | binlog_file_name, |
const Gtid_set * | gtid_set, | ||
const char ** | errmsg | ||
) |
Find the oldest binary log that contains any GTID that is not in the given gtid set.
[out] | binlog_file_name,the | file name of oldest binary log found |
[in] | gtid_set,the | given gtid set |
[out] | errmsg,the | error message outputted, which is left untouched if the function returns false |
Definition at line 2723 of file binlog.cc.
int MYSQL_BIN_LOG::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 |
Definition at line 3410 of file binlog.cc.
int MYSQL_BIN_LOG::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 |
Definition at line 3509 of file binlog.cc.
int binlog_cache_data::flush | ( | THD * | thd, |
my_off_t * | bytes_written, | ||
bool * | wrote_xid | ||
) |
Flush caches to the binary log.
If the cache is finalized, the cache will be flushed to the binary log file. If the cache is not finalized, nothing will be done.
If flushing fails for any reason, an error will be reported and the cache will be reset. Flushing can fail in two circumstances:
Definition at line 1178 of file binlog.cc.
bool MYSQL_BIN_LOG::flush_and_sync | ( | const bool | force = false | ) |
Flush binlog cache and synchronize to disk.
This function flushes events in binlog cache to binary log file, it will do synchronizing according to the setting of system variable 'sync_binlog'. If file is synchronized, synced
will be set to 1, otherwise 0.
[out] | synced | if not NULL, set to 1 if file is synchronized, otherwise 0 |
[in] | force | if TRUE, ignores the 'sync_binlog' and synchronizes the file. |
0 | Success |
other | Failure |
Definition at line 4920 of file binlog.cc.
int gtid_empty_group_log_and_cleanup | ( | THD * | thd | ) |
The function logs an empty group with GTID and performs cleanup. Its logic wrt GTID is equivalent to one of binlog_commit(). It's called at the end of statement execution in case binlog_commit() was skipped. Such cases are due ineffective binlogging incl an empty group re-execution.
thd | The thread handle |
Definition at line 1098 of file binlog.cc.
bool MYSQL_BIN_LOG::init_gtid_sets | ( | Gtid_set * | gtid_set, |
Gtid_set * | lost_groups, | ||
bool | verify_checksum, | ||
bool | need_lock | ||
) |
Reads the set of all GTIDs in the binary log, and the set of all lost GTIDs in the binary log, and stores each set in respective argument.
gtid_set | Will be filled with all GTIDs in this binary log. |
lost_groups | Will be filled with all GTIDs in the Previous_gtids_log_event of the first binary log that has a Previous_gtids_log_event. |
verify_checksum | If true, checksums will be checked. |
need_lock | If true, LOCK_log, LOCK_index, and global_sid_lock->wrlock are acquired; otherwise they are asserted to be taken already. |
Definition at line 2831 of file binlog.cc.
bool MYSQL_BIN_LOG::is_active | ( | const char * | log_file_name_arg | ) |
void MYSQL_BIN_LOG::make_log_name | ( | char * | buf, |
const char * | log_ident | ||
) |
Delete relay log files prior to rli->group_relay_log_name (i.e. all logs which are not involved in a non-finished group (transaction)), remove them from the index file and start on next relay log.
IMPLEMENTATION
rli | Relay log information |
included | If false, all relay logs that are strictly before rli->group_relay_log_name are deleted ; if true, the latter is deleted too (i.e. all relay logs read by the SQL slave thread are deleted). |
0 | ok |
LOG_INFO_EOF | End of log-index-file found |
LOG_INFO_SEEK | Could not allocate IO cache |
LOG_INFO_IO | Got IO error while reading file Create a new log file name. |
buf | buf of at least FN_REFLEN where new name is stored |
Definition at line 4600 of file binlog.cc.
int MYSQL_BIN_LOG::move_crash_safe_index_file_to_index_file | ( | bool | need_lock_index | ) |
int MYSQL_BIN_LOG::open_binlog | ( | const char * | opt_name | ) |
Definition at line 5940 of file binlog.cc.
bool MYSQL_BIN_LOG::open_binlog | ( | const char * | log_name, |
const char * | new_name, | ||
enum cache_type | io_cache_type_arg, | ||
ulong | max_size_arg, | ||
bool | null_created_arg, | ||
bool | need_lock_index, | ||
bool | need_sid_lock, | ||
Format_description_log_event * | extra_description_event | ||
) |
Create a new binary log.
log_name | Name of binlog |
new_name | Name of binlog, too. todo: what's the difference between new_name and log_name? |
io_cache_type_arg | Specifies how the IO cache is opened: read-only or read-write. |
max_size | The size at which this binlog will be rotated. |
null_created | If false, and a Format_description_log_event is written, then the Format_description_log_event will have the timestamp 0. Otherwise, it the timestamp will be the time when the event was written to the log. |
need_lock_index | If true, LOCK_index is acquired; otherwise LOCK_index must be taken by the caller. |
need_sid_lock | If true, the read lock on global_sid_lock will be acquired. Otherwise, the caller must hold the read lock on global_sid_lock. |
Open a (new) binlog file.
0 | ok |
1 | error |
Definition at line 2969 of file binlog.cc.
File open_binlog_file | ( | IO_CACHE * | log, |
const char * | log_file_name, | ||
const char ** | errmsg | ||
) |
int MYSQL_BIN_LOG::open_crash_safe_index_file | ( | ) |
void MYSQL_BIN_LOG::purge | ( | ) |
bool purge_master_logs | ( | THD * | thd, |
const char * | to_log | ||
) |
Execute a PURGE BINARY LOGS TO <log> command.
thd | Pointer to THD object for the client thread executing the statement. |
to_log | Name of the last log to purge. |
FALSE | success |
TRUE | failure |
Definition at line 2022 of file binlog.cc.
bool purge_master_logs_before_date | ( | THD * | thd, |
time_t | purge_time | ||
) |
Execute a PURGE BINARY LOGS BEFORE <date> command.
thd | Pointer to THD object for the client thread executing the statement. |
purge_time | Date before which logs should be purged. |
FALSE | success |
TRUE | failure |
Definition at line 2051 of file binlog.cc.
int MYSQL_BIN_LOG::recover | ( | IO_CACHE * | log, |
Format_description_log_event * | fdle, | ||
my_off_t * | valid_pos | ||
) |
MYSQLD server recovers from last crashed binlog.
log | IO_CACHE of the crashed binlog. |
fdle | Format_description_log_event of the crashed binlog. |
valid_pos | The position of the last valid transaction or event(non-transaction) of the crashed binlog. |
0 | ok |
1 | error |
Definition at line 6896 of file binlog.cc.
bool MYSQL_BIN_LOG::reset_logs | ( | THD * | thd | ) |
Removes files, as part of a RESET MASTER or RESET SLAVE statement, by deleting all logs refered to in the index file. Then, it starts writing to a new log file.
The new index file will only contain this file.
thd | Thread |
0 | ok |
1 | error |
Definition at line 3568 of file binlog.cc.
int MYSQL_BIN_LOG::rollback | ( | THD * | thd, |
bool | all | ||
) |
Write a rollback record of the transaction to the binary log.
For binary log group commit, the rollback is separated into three parts:
Second part execute an ordered flush and commit. This will be done using the group commit functionality in ordered_commit
.
Since we roll back the transaction early, we call ordered_commit
with the skip_commit
flag set. The ha_commit_low
call inside ordered_commit
will then not be called.
thd | Session to commit |
all | This is true if this is a real transaction rollback, and otherwise. |
Definition at line 1520 of file binlog.cc.
int MYSQL_BIN_LOG::rotate | ( | bool | force_rotate, |
bool * | check_purge | ||
) |
The method executes rotation when LOCK_log is already acquired by the caller.
force_rotate | caller can request the log rotation |
check_purge | is set to true if rotation took place |
nonzero | - error in rotating routine. |
Be conservative... There are possible lost events (eg, failing to log the Execute_load_query_log_event on a LOAD DATA while using a non-transactional table)!
We give it a shot and try to write an incident event anyway to the current log.
Definition at line 5200 of file binlog.cc.
int MYSQL_BIN_LOG::rotate_and_purge | ( | bool | force_rotate | ) |
The method is a shortcut of rotate()
and purge()
. LOCK_log is acquired prior to rotate and is released after it.
force_rotate | caller can request the log rotation |
nonzero | - error in rotating routine. |
Definition at line 5278 of file binlog.cc.
int MYSQL_BIN_LOG::set_crash_safe_index_file_name | ( | const char * | base_file_name | ) |
bool stmt_cannot_safely_rollback | ( | const THD * | thd | ) |
bool stmt_has_updated_trans_table | ( | const THD * | thd | ) |
bool trans_cannot_safely_rollback | ( | const THD * | thd | ) |
bool trans_has_updated_trans_table | ( | const THD * | thd | ) |
int binlog_trx_cache_data::truncate | ( | THD * | thd, |
bool | all | ||
) |
This function truncates the transactional cache upon committing or rolling back either a transaction or a statement.
thd | The thread whose transaction should be flushed |
cache_mngr | Pointer to the cache data to be flushed |
all | true means truncate the transaction, otherwise the statement must be truncated. |
Definition at line 1233 of file binlog.cc.
int MYSQL_BIN_LOG::wait_for_update_bin_log | ( | THD * | thd, |
const struct timespec * | timeout | ||
) |
Wait until we get a signal that the binary log has been updated. Applies to master only.
NOTES
[in] | thd | a THD struct |
[in] | timeout | a pointer to a timespec; NULL means to wait w/o timeout. |
0 | if got signalled on update |
non-0 | if wait timeout elapsed |
int MYSQL_BIN_LOG::wait_for_update_relay_log | ( | THD * | thd, |
const struct timespec * | timeout | ||
) |
Wait until we get a signal that the relay log has been updated.
[in] | thd | Thread variable |
[in] | timeout | a pointer to a timespec; NULL means to wait w/o timeout. |
0 | if got signalled on update |
non-0 | if wait timeout elapsed |
bool MYSQL_BIN_LOG::write_cache | ( | THD * | thd, |
class binlog_cache_data * | binlog_cache_data | ||
) |
Write a cached log entry to the binary log.
thd | Thread variable |
cache | The cache to copy to the binlog |
incident | Defines if an incident event should be created to notify that some non-transactional changes did not get into the binlog. |
prepared | Defines if a transaction is part of a 2-PC. |
Definition at line 5680 of file binlog.cc.
bool MYSQL_BIN_LOG::write_event | ( | Log_event * | event_info | ) |
bool MYSQL_BIN_LOG::write_incident | ( | THD * | thd, |
bool | need_lock_log, | ||
bool | do_flush_and_sync = true |
||
) |
bool MYSQL_BIN_LOG::write_incident | ( | Incident_log_event * | ev, |
bool | need_lock_log, | ||
bool | do_flush_and_sync = true |
||
) |
Writes an incident event to the binary log.
ev | Incident event to be written |
need_lock_log | If true, will acquire LOCK_log; otherwise the caller should already have acquired LOCK_log. If true, will call flush_and_sync(), rotate() and purge(). |
false | error |
true | success |
Definition at line 5599 of file binlog.cc.
struct st_mysql_storage_engine binlog_storage_engine |