MCPcopy Create free account
hub / github.com/Tencent/phxsql / sync_binlog_file

Method sync_binlog_file

phx_percona/percona/sql/binlog.cc:7101–7135  ·  view source on GitHub ↗

Call fsync() to sync the file to disk. */

Source from the content-addressed store, hash-verified

7099 Call fsync() to sync the file to disk.
7100*/
7101std::pair<bool, bool>
7102MYSQL_BIN_LOG::sync_binlog_file(bool force)
7103{
7104 bool synced= false;
7105 unsigned int sync_period= get_sync_period();
7106 if (force || (sync_period && ++sync_counter >= sync_period))
7107 {
7108 sync_counter= 0;
7109
7110 /**
7111 On *pure non-transactional* workloads there is a small window
7112 in time where a concurrent rotate might be able to close
7113 the file before the sync is actually done. In that case,
7114 ignore the bad file descriptor errors.
7115
7116 Transactional workloads (InnoDB) are not affected since the
7117 the rotation will not happen until all transactions have
7118 committed to the storage engine, thence decreased the XID
7119 counters.
7120
7121 TODO: fix this properly even for non-transactional storage
7122 engines.
7123 */
7124 if (DBUG_EVALUATE_IF("simulate_error_during_sync_binlog_file", 1,
7125 mysql_file_sync(log_file.file,
7126 MYF(MY_WME | MY_IGNORE_BADFD))))
7127 {
7128 THD *thd= current_thd;
7129 thd->commit_error= THD::CE_SYNC_ERROR;
7130 return std::make_pair(true, synced);
7131 }
7132 synced= true;
7133 }
7134 return std::make_pair(false, synced);
7135}
7136
7137
7138/**

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected