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

Method ordered_commit

phx_percona/percona/sql/binlog.cc:7343–7578  ·  view source on GitHub ↗

Flush and commit the transaction. This will execute an ordered flush and commit of all outstanding transactions and is the main function for the binary log group commit logic. The function performs the ordered commit in two phases. The first phase flushes the caches to the binary log and under LOCK_log and marks all threads that were flushed as not pending. The second phase execut

Source from the content-addressed store, hash-verified

7341 false otherwise (the normal case).
7342 */
7343int MYSQL_BIN_LOG::ordered_commit(THD *thd, bool all, bool skip_commit)
7344{
7345 DBUG_ENTER("MYSQL_BIN_LOG::ordered_commit");
7346 int flush_error= 0, sync_error= 0;
7347 my_off_t total_bytes= 0;
7348 bool do_rotate= false;
7349
7350 /*
7351 These values are used while flushing a transaction, so clear
7352 everything.
7353
7354 Notes:
7355
7356 - It would be good if we could keep transaction coordinator
7357 log-specific data out of the THD structure, but that is not the
7358 case right now.
7359
7360 - Everything in the transaction structure is reset when calling
7361 ha_commit_low since that calls st_transaction::cleanup.
7362 */
7363 thd->transaction.flags.pending= true;
7364 thd->commit_error= THD::CE_NONE;
7365 thd->next_to_commit= NULL;
7366 thd->durability_property= HA_IGNORE_DURABILITY;
7367 thd->transaction.flags.real_commit= all;
7368 thd->transaction.flags.xid_written= false;
7369 thd->transaction.flags.commit_low= !skip_commit;
7370 thd->transaction.flags.run_hooks= !skip_commit;
7371#ifndef DBUG_OFF
7372 /*
7373 The group commit Leader may have to wait for follower whose transaction
7374 is not ready to be preempted. Initially the status is pessimistic.
7375 Preemption guarding logics is necessary only when DBUG_ON is set.
7376 It won't be required for the dbug-off case as long as the follower won't
7377 execute any thread-specific write access code in this method, which is
7378 the case as of current.
7379 */
7380 thd->transaction.flags.ready_preempt= 0;
7381#endif
7382
7383 DBUG_PRINT("enter", ("flags.pending: %s, commit_error: %d, thread_id: %lu",
7384 YESNO(thd->transaction.flags.pending),
7385 thd->commit_error, thd->thread_id));
7386
7387 /*
7388 Stage #1: flushing transactions to binary log
7389
7390 While flushing, we allow new threads to enter and will process
7391 them in due time. Once the queue was empty, we cannot reap
7392 anything more since it is possible that a thread entered and
7393 appointed itself leader for the flush phase.
7394 */
7395 DEBUG_SYNC(thd, "waiting_to_enter_flush_stage");
7396 if (change_stage(thd, Stage_manager::FLUSH_STAGE, thd, NULL, &LOCK_log))
7397 {
7398 DBUG_PRINT("return", ("Thread ID: %lu, commit_error: %d",
7399 thd->thread_id, thd->commit_error));
7400 DBUG_RETURN(finish_commit(thd));

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected