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

Method finish_commit

phx_percona/percona/sql/binlog.cc:7158–7233  ·  view source on GitHub ↗

Helper function executed when leaving @c ordered_commit. This function contain the necessary code for fetching the error code, doing post-commit checks, and wrapping up the commit if necessary. It is typically called when enter_stage indicates that the thread should bail out, and also when the ultimate leader thread finishes executing @c ordered_commit. It is typically used

Source from the content-addressed store, hash-verified

7156 success.
7157 */
7158int
7159MYSQL_BIN_LOG::finish_commit(THD *thd)
7160{
7161 /*
7162 In some unlikely situations, it can happen that binary
7163 log is closed before the thread flushes it's cache.
7164 In that case, clear the caches before doing commit.
7165 */
7166 if (unlikely(!is_open()))
7167 {
7168 binlog_cache_mngr *cache_mngr= thd_get_cache_mngr(thd);
7169 if (cache_mngr)
7170 cache_mngr->reset();
7171 }
7172 if (thd->transaction.flags.commit_low)
7173 {
7174 const bool all= thd->transaction.flags.real_commit;
7175 /*
7176 storage engine commit
7177 */
7178 DBUG_ASSERT(thd->commit_error != THD::CE_COMMIT_ERROR);
7179 if (thd->commit_error == THD::CE_NONE)
7180 {
7181 /*
7182 Acquire a shared lock to block commits if an X lock has been acquired by
7183 LOCK TABLES FOR BACKUP or START TRANSACTION WITH CONSISTENT SNAPSHOT. We
7184 only reach this code if binlog_order_commits=0.
7185 */
7186 DBUG_ASSERT(opt_binlog_order_commits == 0);
7187
7188 slock();
7189
7190 if (ha_commit_low(thd, all, false))
7191 thd->commit_error= THD::CE_COMMIT_ERROR;
7192
7193 sunlock();
7194 }
7195 /*
7196 Decrement the prepared XID counter after storage engine commit
7197 */
7198 if (thd->transaction.flags.xid_written)
7199 dec_prep_xids(thd);
7200 /*
7201 If commit succeeded, we call the after_commit hook
7202
7203 TODO: This hook here should probably move outside/below this
7204 if and be the only after_commit invocation left in the
7205 code.
7206 */
7207 if ((thd->commit_error != THD::CE_COMMIT_ERROR ) && thd->transaction.flags.run_hooks)
7208 {
7209 (void) RUN_HOOK(transaction, after_commit, (thd, all));
7210 thd->transaction.flags.run_hooks= false;
7211 }
7212 }
7213 else if (thd->transaction.flags.xid_written)
7214 dec_prep_xids(thd);
7215

Callers

nothing calls this directly

Calls 3

thd_get_cache_mngrFunction · 0.85
dbug_any_finalizedMethod · 0.80
resetMethod · 0.45

Tested by

no test coverage detected