MCPcopy Create free account
hub / github.com/MariaDB/server / commit

Method commit

sql/log.cc:15169–15263  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15167}
15168
15169bool Binlog_commit_by_rotate::commit(MYSQL_BIN_LOG::group_commit_entry *entry)
15170{
15171 bool check_purge= false;
15172 THD *thd= entry->thd;
15173 binlog_cache_mngr *cache_mngr= entry->cache_mngr;
15174 binlog_cache_data *cache_data= cache_mngr->get_binlog_cache_data(true);
15175 if (unlikely(!cache_mngr->using_trx_cache || cache_data->empty()))
15176 cache_data= cache_mngr->get_binlog_cache_data(false);
15177
15178 /* Call them before enter log_lock to avoid holding the lock long */
15179 if (cache_data->sync_temp_file())
15180 return true;
15181
15182 /*
15183 If there was a rollback_to_savepoint happened before, the real length of
15184 tmp file can be greater than the file_end_pos. Truncate the cache tmp
15185 file to file_end_pos of this cache.
15186 */
15187 my_chsize(cache_data->cache_log.file, cache_data->temp_file_length(), 0,
15188 MYF(0));
15189
15190 if (thd->wait_for_prior_commit())
15191 return true;
15192
15193 // It will be released by trx_group_commit_with_engines
15194 mysql_mutex_lock(&mysql_bin_log.LOCK_log);
15195
15196 enum enum_binlog_checksum_alg expected_alg=
15197 mysql_bin_log.checksum_alg_reset != BINLOG_CHECKSUM_ALG_UNDEF
15198 ? mysql_bin_log.checksum_alg_reset
15199 : (enum_binlog_checksum_alg) binlog_checksum_options;
15200
15201 /*
15202 In legacy mode, all events should has a valid position this done by
15203 updating log_pos field when writing events from binlog cache to binlog
15204 file. Thus rename binlog cache to binlog file is not supported in legacy
15205 mode.
15206
15207 if the cache's checksum alg is not same to the binlog's checksum, it needs
15208 to recalculate the checksum. Thus rename binlog cache to binlog file is
15209 not supported.
15210 */
15211 if (!mysql_bin_log.is_open() || opt_binlog_legacy_event_pos ||
15212 (expected_alg != cache_data->checksum_opt))
15213 {
15214 mysql_mutex_unlock(&mysql_bin_log.LOCK_log);
15215 // It cannot do rename, so go to group commit
15216 return mysql_bin_log.write_transaction_with_group_commit(entry);
15217 }
15218
15219 m_entry= entry;
15220 m_replaced= false;
15221 m_cache_data= cache_data;
15222 ulong prev_binlog_id= mysql_bin_log.current_binlog_id;
15223
15224 /*
15225 Rotate will call replace_binlog_file() to rename the transaction's binlog
15226 cache to the new binlog file.

Calls 14

my_chsizeFunction · 0.85
reinit_io_cacheFunction · 0.85
get_binlog_cache_dataMethod · 0.80
sync_temp_fileMethod · 0.80
temp_file_lengthMethod · 0.80
rotateMethod · 0.80
checkpoint_and_purgeMethod · 0.80
get_byte_positionMethod · 0.80
detach_temp_fileMethod · 0.80
emptyMethod · 0.45

Tested by

no test coverage detected