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

Method commit

phx_percona/percona/sql/binlog.cc:6596–6792  ·  view source on GitHub ↗

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 @c 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

Source from the content-addressed store, hash-verified

6594 @retval 2 error, transaction was logged but not committed
6595*/
6596TC_LOG::enum_result MYSQL_BIN_LOG::commit(THD *thd, bool all)
6597{
6598 DBUG_ENTER("MYSQL_BIN_LOG::commit");
6599
6600 binlog_cache_mngr *cache_mngr= thd_get_cache_mngr(thd);
6601 my_xid xid= thd->transaction.xid_state.xid.get_my_xid();
6602 int error= RESULT_SUCCESS;
6603 bool stuff_logged= false;
6604 bool binlog_prot_acquired= false;
6605
6606 DBUG_PRINT("enter", ("thd: 0x%llx, all: %s, xid: %llu, cache_mngr: 0x%llx",
6607 (ulonglong) thd, YESNO(all), (ulonglong) xid,
6608 (ulonglong) cache_mngr));
6609
6610 /*
6611 No cache manager means nothing to log, but we still have to commit
6612 the transaction.
6613 */
6614 if (cache_mngr == NULL)
6615 {
6616 if (ha_commit_low(thd, all))
6617 DBUG_RETURN(RESULT_ABORTED);
6618 DBUG_RETURN(RESULT_SUCCESS);
6619 }
6620
6621 /*
6622 Reset binlog_snapshot_% variables for the current connection so that the
6623 current coordinates are shown after committing a consistent snapshot
6624 transaction.
6625 */
6626 if (all)
6627 {
6628 mysql_mutex_lock(&cache_mngr->binlog_info.lock);
6629 cache_mngr->binlog_info.log_file_name[0]= '\0';
6630 mysql_mutex_unlock(&cache_mngr->binlog_info.lock);
6631 }
6632
6633 THD_TRANS *trans= all ? &thd->transaction.all : &thd->transaction.stmt;
6634
6635 DBUG_PRINT("debug", ("in_transaction: %s, no_2pc: %s, rw_ha_count: %d",
6636 YESNO(thd->in_multi_stmt_transaction_mode()),
6637 YESNO(trans->no_2pc),
6638 trans->rw_ha_count));
6639 DBUG_PRINT("debug",
6640 ("all.cannot_safely_rollback(): %s, trx_cache_empty: %s",
6641 YESNO(thd->transaction.all.cannot_safely_rollback()),
6642 YESNO(cache_mngr->trx_cache.is_binlog_empty())));
6643 DBUG_PRINT("debug",
6644 ("stmt.cannot_safely_rollback(): %s, stmt_cache_empty: %s",
6645 YESNO(thd->transaction.stmt.cannot_safely_rollback()),
6646 YESNO(cache_mngr->stmt_cache.is_binlog_empty())));
6647
6648
6649 /*
6650 If there are no handlertons registered, there is nothing to
6651 commit. Note that DDLs are written earlier in this case (inside
6652 binlog_query).
6653

Callers 1

Calls 7

thd_get_cache_mngrFunction · 0.85
ending_transFunction · 0.85
finalizeMethod · 0.80
set_prev_positionMethod · 0.80
is_binlog_emptyMethod · 0.45
resetMethod · 0.45

Tested by

no test coverage detected