#ifdef UNIV_DEBUG void rw_trx_hash_t::validate_element(trx_t *trx)
{
ut_ad(!trx->read_only || !trx->rsegs.m_redo.rseg);
ut_ad(!trx->is_autocommit_non_locking());
ut_d(bool acquire_trx_mutex= !trx->mutex_is_owner());
ut_d(if (acquire_trx_mutex) trx->mutex_lock()); switch (trx->state) { case TRX_STATE_NOT_STARTED: case TRX_STATE_ABORTED:
ut_error; case TRX_STATE_PREPARED: case TRX_STATE_PREPARED_RECOVERED: case TRX_STATE_COMMITTED_IN_MEMORY:
ut_ad(!trx->is_autocommit_non_locking()); break; case TRX_STATE_ACTIVE: if (!trx->is_autocommit_non_locking()) break;
ut_ad(!trx->is_recovered);
ut_ad(trx->read_only);
ut_ad(trx->mysql_thd);
}
ut_d(if (acquire_trx_mutex) trx->mutex_unlock());
} #endif
/** Display the MySQL binlog offset info if it is present in the trx
system header. */ void
trx_sys_print_mysql_binlog_offset()
{ if (!*trx_sys.recovered_binlog_filename) { return;
}
/** Initialize the transaction system when creating the database. */
dberr_t trx_sys_create_sys_pages(mtr_t *mtr)
{
mtr->x_lock_space(fil_system.sys_space);
static_assert(TRX_SYS_SPACE == 0, "compatibility");
/* Create the trx sys file block in a new allocated file segment */
dberr_t err;
buf_block_t *block= fseg_create(fil_system.sys_space,
TRX_SYS + TRX_SYS_FSEG_HEADER, mtr, &err); if (UNIV_UNLIKELY(!block)) return err;
ut_a(block->page.id() == page_id_t(0, TRX_SYS_PAGE_NO));
/** Create the rollback segments.
@return whether the creation succeeded */ bool trx_sys_create_rsegs()
{ /* srv_available_undo_logs reflects the number of persistent rollbacksegmentsthathavebeeninitializedinthe
transaction system header page. */
ut_ad(srv_undo_tablespaces <= TRX_SYS_MAX_UNDO_SPACES);
if (high_level_read_only) {
srv_available_undo_logs = 0; return(true);
}
/* This is executed in single-threaded mode therefore it is not necessarytousethesamemtrintrx_rseg_create().n_usedcannot
change while the function is executing. */
trx_sysf_get_n_rseg_slots();
/* The first persistent rollback segment is always initialized
in the system tablespace. */
ut_a(srv_available_undo_logs > 0);
for (uint32_t i = 0; srv_available_undo_logs < TRX_SYS_N_RSEGS;
i++, srv_available_undo_logs++) { /* Tablespace 0 is the system tablespace.
Dedicated undo log tablespaces start from 1. */
uint32_t space = srv_undo_tablespaces > 0
? (i % srv_undo_tablespaces)
+ srv_undo_space_id_start
: TRX_SYS_SPACE;
if (!trx_rseg_create(space)) {
ib::error() << "Unable to allocate the" " requested innodb_undo_logs"; return(false);
}
/* Increase the number of active undo tablespaceincasenewrollbacksegment
assigned to new undo tablespace. */ if (space > (srv_undo_space_id_start
+ srv_undo_tablespaces_active - 1)) {
srv_undo_tablespaces_active++;
}
}
ib::info info;
info << srv_available_undo_logs; if (srv_undo_tablespaces_active) {
info << " rollback segments in " << srv_undo_tablespaces_active
<< " undo tablespaces are active.";
} else {
info << " rollback segments are active.";
}
return(true);
}
/** Close the transaction system on shutdown */ void
trx_sys_t::close()
{
ut_ad(srv_shutdown_state == SRV_SHUTDOWN_EXIT_THREADS); if (!is_initialised()) { return;
}
if (size_t size = view_count()) {
ib::error() << "All read views were not closed before" " shutdown: " << size << " read views open";
}
rw_trx_hash.destroy();
rw_trx_ids.destroy();
/* There can't be any active transactions. */ for (auto& rseg : temp_rsegs) rseg.destroy(); for (auto& rseg : rseg_array) rseg.destroy();
/** @return total number of active (non-prepared) transactions */
size_t trx_sys_t::any_active_transactions(size_t *prepared)
{
size_t total_trx= 0, prepared_trx= 0;
trx_sys.trx_list.for_each([&](const trx_t &trx) { switch (trx.state) { case TRX_STATE_NOT_STARTED: case TRX_STATE_ABORTED: break; case TRX_STATE_ACTIVE: if (!trx.id) break; /* fall through */ case TRX_STATE_COMMITTED_IN_MEMORY:
total_trx++; break; case TRX_STATE_PREPARED: case TRX_STATE_PREPARED_RECOVERED:
prepared_trx++;
}
});
if (prepared)
*prepared= prepared_trx;
return total_trx;
}
#ifndef EMBEDDED_LIBRARY /** @return true if any active (non-prepared) transactions is recovered */ bool trx_sys_t::any_active_transaction_recovered()
{ return trx_sys.trx_list.find_first([&](trx_t &trx)
{ if (trx.state != TRX_STATE_ACTIVE) returnfalse;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.