Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion storage/innobase/handler/ha_innodb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2953,7 +2953,7 @@ static int innobase_close_connection(handlerton *, THD *thd) noexcept
case TRX_STATE_PREPARED:
if (trx->has_logged_persistent())
{
trx_disconnect_prepared(trx);
trx->disconnect_prepared();
return 0;
}
/* fall through */
Expand Down
36 changes: 13 additions & 23 deletions storage/innobase/handler/i_s.cc
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,7 @@ static bool trx_i_s_common_fill_table(THD *thd, TABLE_LIST *tables)
RETURN_IF_INNODB_NOT_STARTED(tables->schema_table_name.str);

/* update the cache */
trx_i_s_cache_start_write(trx_i_s_cache);
trx_i_s_possibly_fetch_data_into_cache(trx_i_s_cache);
trx_i_s_cache_end_write(trx_i_s_cache);

if (trx_i_s_cache_is_truncated(trx_i_s_cache))
if (trx_i_s_possibly_fetch_data_into_cache())
sql_print_warning("InnoDB: Data in %.*s truncated due to memory limit"
" of %u bytes",
int(tables->schema_table_name.length),
Expand Down Expand Up @@ -380,22 +376,20 @@ static int fill_innodb_trx_from_cache(THD *thd, TABLE_LIST *tables, Item*)

struct cache
{
cache() { trx_i_s_cache_start_read(trx_i_s_cache); }
~cache() { trx_i_s_cache_end_read(trx_i_s_cache); }
cache() { trx_i_s_cache_start_read(); }
~cache() { trx_i_s_cache_end_read(); }
} c;

Field** fields = tables->table->field;

rows_num = trx_i_s_cache_get_rows_used(trx_i_s_cache,
I_S_INNODB_TRX);
rows_num = trx_i_s_cache_get_rows_used(I_S_INNODB_TRX);

for (i = 0; i < rows_num; i++) {

i_s_trx_row_t* row;

row = (i_s_trx_row_t*)
trx_i_s_cache_get_nth_row(
trx_i_s_cache, I_S_INNODB_TRX, i);
trx_i_s_cache_get_nth_row(I_S_INNODB_TRX, i);

/* trx_id */
OK(fields[IDX_TRX_ID]->store(row->trx_id, true));
Expand Down Expand Up @@ -669,14 +663,13 @@ fill_innodb_locks_from_cache(

struct cache
{
cache() { trx_i_s_cache_start_read(trx_i_s_cache); }
~cache() { trx_i_s_cache_end_read(trx_i_s_cache); }
cache() { trx_i_s_cache_start_read(); }
~cache() { trx_i_s_cache_end_read(); }
} c;

Field** fields = tables->table->field;

rows_num = trx_i_s_cache_get_rows_used(trx_i_s_cache,
I_S_INNODB_LOCKS);
rows_num = trx_i_s_cache_get_rows_used(I_S_INNODB_LOCKS);

for (i = 0; i < rows_num; i++) {

Expand All @@ -685,8 +678,7 @@ fill_innodb_locks_from_cache(
const char* bufend;

row = (i_s_locks_row_t*)
trx_i_s_cache_get_nth_row(
trx_i_s_cache, I_S_INNODB_LOCKS, i);
trx_i_s_cache_get_nth_row(I_S_INNODB_LOCKS, i);

/* lock_id */
trx_i_s_create_lock_id(row, lock_id, sizeof(lock_id));
Expand Down Expand Up @@ -855,22 +847,20 @@ fill_innodb_lock_waits_from_cache(

struct cache
{
cache() { trx_i_s_cache_start_read(trx_i_s_cache); }
~cache() { trx_i_s_cache_end_read(trx_i_s_cache); }
cache() { trx_i_s_cache_start_read(); }
~cache() { trx_i_s_cache_end_read(); }
} c;

Field** fields = tables->table->field;

rows_num = trx_i_s_cache_get_rows_used(trx_i_s_cache,
I_S_INNODB_LOCK_WAITS);
rows_num = trx_i_s_cache_get_rows_used(I_S_INNODB_LOCK_WAITS);

for (i = 0; i < rows_num; i++) {

i_s_lock_waits_row_t* row;

row = (i_s_lock_waits_row_t*)
trx_i_s_cache_get_nth_row(
trx_i_s_cache, I_S_INNODB_LOCK_WAITS, i);
trx_i_s_cache_get_nth_row(I_S_INNODB_LOCK_WAITS, i);

/* requesting_trx_id */
OK(fields[IDX_REQUESTING_TRX_ID]->store(
Expand Down
75 changes: 12 additions & 63 deletions storage/innobase/include/trx0i_s.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,6 @@ struct i_s_lock_waits_row_t {
const i_s_locks_row_t* blocking_lock_row; /*!< blocking lock */
};

/** Cache of INFORMATION_SCHEMA table data */
struct trx_i_s_cache_t;

/** Auxiliary enum used by functions that need to select one of the
INFORMATION_SCHEMA tables */
enum i_s_table {
Expand All @@ -157,90 +154,42 @@ enum i_s_table {
I_S_INNODB_LOCK_WAITS /*!< INFORMATION_SCHEMA.innodb_lock_waits */
};

/** This is the intermediate buffer where data needed to fill the
INFORMATION SCHEMA tables is fetched and later retrieved by the C++
code in handler/i_s.cc. */
extern trx_i_s_cache_t* trx_i_s_cache;

/*******************************************************************//**
Initialize INFORMATION SCHEMA trx related cache. */
void
trx_i_s_cache_init(
/*===============*/
trx_i_s_cache_t* cache); /*!< out: cache to init */
void trx_i_s_cache_init();
/*******************************************************************//**
Free the INFORMATION SCHEMA trx related cache. */
void
trx_i_s_cache_free(
/*===============*/
trx_i_s_cache_t* cache); /*!< in/out: cache to free */
void trx_i_s_cache_free();

/*******************************************************************//**
Issue a shared/read lock on the tables cache. */
void
trx_i_s_cache_start_read(
/*=====================*/
trx_i_s_cache_t* cache); /*!< in: cache */
void trx_i_s_cache_start_read() noexcept;

/*******************************************************************//**
Release a shared/read lock on the tables cache. */
void
trx_i_s_cache_end_read(
/*===================*/
trx_i_s_cache_t* cache); /*!< in: cache */

/*******************************************************************//**
Issue an exclusive/write lock on the tables cache. */
void
trx_i_s_cache_start_write(
/*======================*/
trx_i_s_cache_t* cache); /*!< in: cache */

/*******************************************************************//**
Release an exclusive/write lock on the tables cache. */
void
trx_i_s_cache_end_write(
/*====================*/
trx_i_s_cache_t* cache); /*!< in: cache */

void trx_i_s_cache_end_read() noexcept;

/*******************************************************************//**
Retrieves the number of used rows in the cache for a given
INFORMATION SCHEMA table.
@param table table to be read
@return number of rows */
ulint
trx_i_s_cache_get_rows_used(
/*========================*/
trx_i_s_cache_t* cache, /*!< in: cache */
enum i_s_table table); /*!< in: which table */
ulint trx_i_s_cache_get_rows_used(i_s_table table);

/*******************************************************************//**
Retrieves the nth row in the cache for a given INFORMATION SCHEMA
table.
@param table table to read
@param n row number
@return row */
void*
trx_i_s_cache_get_nth_row(
/*======================*/
trx_i_s_cache_t* cache, /*!< in: cache */
enum i_s_table table, /*!< in: which table */
ulint n); /*!< in: row number */
void *trx_i_s_cache_get_nth_row(i_s_table table, ulint n);

/*******************************************************************//**
Update the transactions cache if it has not been read for some time.
@return 0 - fetched, 1 - not */
int
trx_i_s_possibly_fetch_data_into_cache(
/*===================================*/
trx_i_s_cache_t* cache); /*!< in/out: cache */
@retval false when fetched or cached
@retval true if fetched but the cache was truncated */
bool trx_i_s_possibly_fetch_data_into_cache();

/*******************************************************************//**
Returns true, if the data in the cache is truncated due to the memory
limit posed by TRX_I_S_MEM_LIMIT.
@return TRUE if truncated */
bool
trx_i_s_cache_is_truncated(
/*=======================*/
trx_i_s_cache_t* cache); /*!< in: cache */
/** The maximum length of a resulting lock_id_size in
trx_i_s_create_lock_id(), not including the terminating NUL.
":%lu:%lu:%lu" -> 63 chars */
Expand Down
3 changes: 0 additions & 3 deletions storage/innobase/include/trx0sys.h
Original file line number Diff line number Diff line change
Expand Up @@ -825,9 +825,6 @@ class thread_safe_trx_ilist_t
mysql_mutex_unlock(&mutex);
}

void freeze() const { mysql_mutex_lock(&mutex); }
void unfreeze() const { mysql_mutex_unlock(&mutex); }

private:
alignas(CPU_LEVEL1_DCACHE_LINESIZE) mutable mysql_mutex_t mutex;
alignas(CPU_LEVEL1_DCACHE_LINESIZE) ilist<trx_t> trx_list;
Expand Down
8 changes: 3 additions & 5 deletions storage/innobase/include/trx0trx.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,6 @@ trx_t *trx_create();
/** At shutdown, frees a transaction object. */
void trx_free_at_shutdown(trx_t *trx);

/** Disconnect a prepared transaction from MySQL.
@param[in,out] trx transaction */
void trx_disconnect_prepared(trx_t *trx);

/** Initialize (resurrect) transactions at startup. */
dberr_t trx_lists_init_at_db_start();

Expand Down Expand Up @@ -730,7 +726,7 @@ struct trx_t : ilist_node<>
This field is accessed by the thread that owns the transaction,
without holding any mutex.
There is only one foreign-thread access in trx_print_low()
and a possible race condition with trx_disconnect_prepared(). */
and a possible race condition with disconnect_prepared(). */
bool is_recovered;
const char* op_info; /*!< English text describing the
current operation, or an empty
Expand Down Expand Up @@ -968,6 +964,8 @@ struct trx_t : ilist_node<>
public:
/** Commit the transaction. */
void commit() noexcept;
/** Disconnect a prepared transaction */
void disconnect_prepared() noexcept;

/** Try to drop a persistent table.
@param table persistent table
Expand Down
4 changes: 2 additions & 2 deletions storage/innobase/srv/srv0srv.cc
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ static void srv_init()
&page_zip_stat_per_index_mutex, nullptr);

/* Initialize some INFORMATION SCHEMA internal structures */
trx_i_s_cache_init(trx_i_s_cache);
trx_i_s_cache_init();
}

/*********************************************************************//**
Expand All @@ -638,7 +638,7 @@ srv_free(void)
mysql_mutex_destroy(&page_zip_stat_per_index_mutex);
mysql_mutex_destroy(&srv_sys.tasks_mutex);

trx_i_s_cache_free(trx_i_s_cache);
trx_i_s_cache_free();
srv_thread_pool_end();
}

Expand Down
Loading