Commit ed6b2307 authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-25919 preparation: Remove trx_t::internal

With commit 1bd681c8 (MDEV-25506)
it no longer is necessary to run DDL and DML operations in
separate transactions. Let us remove the flag trx_t::internal.
Dictionary transactions will be distinguished by trx_t::dict_operation.
parent 0a67b15a
......@@ -542,10 +542,7 @@ dberr_t dict_stats_exec_sql(pars_info_t *pinfo, const char* sql, trx_t *trx)
return que_eval_sql(pinfo, sql, FALSE, trx);
trx= trx_create();
if (srv_read_only_mode)
trx_start_internal_read_only(trx);
else
trx_start_internal(trx);
trx_start_internal(trx);
trx->dict_operation_lock_mode= RW_X_LATCH;
dberr_t err= que_eval_sql(pinfo, sql, FALSE, trx);
......@@ -2589,7 +2586,6 @@ dict_stats_save_index_stat(
char db_utf8[MAX_DB_UTF8_LEN];
char table_utf8[MAX_TABLE_UTF8_LEN];
ut_ad(!trx || trx->internal || trx->mysql_thd);
ut_d(dict_sys.assert_locked());
dict_fs2utf8(index->table->name.m_name, db_utf8, sizeof(db_utf8),
......@@ -3247,11 +3243,7 @@ dict_stats_fetch_from_ps(
trx->isolation_level = TRX_ISO_READ_UNCOMMITTED;
if (srv_read_only_mode) {
trx_start_internal_read_only(trx);
} else {
trx_start_internal(trx);
}
trx_start_internal(trx);
dict_fs2utf8(table->name.m_name, db_utf8, sizeof(db_utf8),
table_utf8, sizeof(table_utf8));
......
......@@ -2550,6 +2550,10 @@ fts_cmp_set_sync_doc_id(
to the one stored in CONFIG
table */
{
if (srv_read_only_mode) {
return DB_READ_ONLY;
}
trx_t* trx;
pars_info_t* info;
dberr_t error;
......@@ -2566,11 +2570,7 @@ fts_cmp_set_sync_doc_id(
fts_table.table = table;
trx = trx_create();
if (srv_read_only_mode) {
trx_start_internal_read_only(trx);
} else {
trx_start_internal(trx);
}
trx_start_internal(trx);
trx->op_info = "update the next FTS document id";
......@@ -5788,11 +5788,11 @@ fts_load_stopword(
if (!trx) {
trx = trx_create();
if (srv_read_only_mode) {
trx_start_internal_read_only(trx);
} else {
trx_start_internal(trx);
}
#ifdef UNIV_DEBUG
trx->start_line = __LINE__;
trx->start_file = __FILE__;
#endif
trx_start_internal_low(trx, !high_level_read_only);
trx->op_info = "upload FTS stopword";
new_trx = TRUE;
}
......
......@@ -11363,8 +11363,9 @@ innobase_fts_load_stopword(
mysql_mutex_unlock(&LOCK_global_system_variables);
}
return fts_load_stopword(table, trx, stopword_table,
THDVAR(thd, ft_enable_stopword), false);
return !high_level_read_only &&
fts_load_stopword(table, trx, stopword_table,
THDVAR(thd, ft_enable_stopword), false);
}
/** Parse the table name into normal name and remote path if needed.
......@@ -13387,7 +13388,6 @@ int ha_innobase::delete_table(const char *name)
ut_ad(trx->will_lock);
ut_ad(trx->state == TRX_STATE_ACTIVE);
trx->dict_operation= true;
trx->internal= true;
}
else
{
......
......@@ -95,18 +95,11 @@ trx_start_if_not_started_low(
trx_t* trx, /*!< in/out: transaction */
bool read_write); /*!< in: true if read write transaction */
/*************************************************************//**
Starts a transaction for internal processing. */
void
trx_start_internal_low(
/*===================*/
trx_t* trx); /*!< in/out: transaction */
/** Starts a read-only transaction for internal processing.
@param[in,out] trx transaction to be started */
void
trx_start_internal_read_only_low(
trx_t* trx);
/**
Start a transaction for internal processing.
@param trx transaction
@param read_write whether writes may be performed */
void trx_start_internal_low(trx_t *trx, bool read_write);
#ifdef UNIV_DEBUG
#define trx_start_if_not_started_xa(t, rw) \
......@@ -127,24 +120,13 @@ trx_start_internal_read_only_low(
do { \
(t)->start_line = __LINE__; \
(t)->start_file = __FILE__; \
trx_start_internal_low((t)); \
} while (false)
#define trx_start_internal_read_only(t) \
do { \
(t)->start_line = __LINE__; \
(t)->start_file = __FILE__; \
trx_start_internal_read_only_low(t); \
trx_start_internal_low(t, true); \
} while (false)
#else
#define trx_start_if_not_started(t, rw) \
trx_start_if_not_started_low((t), rw)
#define trx_start_internal(t) \
trx_start_internal_low((t))
#define trx_start_internal_read_only(t) \
trx_start_internal_read_only_low(t)
#define trx_start_internal(t) trx_start_internal_low(t, true)
#define trx_start_if_not_started_xa(t, rw) \
trx_start_if_not_started_xa_low((t), (rw))
......@@ -848,12 +830,6 @@ struct trx_t : ilist_node<>
count of tables being flushed. */
/*------------------------------*/
bool internal; /*!< true if it is a system/internal
transaction background task. This
includes DDL transactions too. Such
transactions are always treated as
read-write. */
/*------------------------------*/
#ifdef UNIV_DEBUG
unsigned start_line; /*!< Track where it was started from */
const char* start_file; /*!< Filename where it was started */
......
......@@ -2635,7 +2635,7 @@ row_ins_clust_index_entry_low(
&& page_is_empty(block->frame)
&& !entry->is_metadata() && !trx->duplicates
&& !trx->check_unique_secondary && !trx->check_foreigns
&& !trx->dict_operation && !trx->internal
&& !trx->dict_operation
&& block->page.id().page_no() == index->page
&& !index->table->skip_alter_undo
&& !index->table->n_rec_locks
......
......@@ -280,8 +280,7 @@ trx_purge_add_undo_to_history(const trx_t* trx, trx_undo_t*& undo, mtr_t* mtr)
&& (srv_is_being_started
|| trx_rollback_is_active
|| srv_force_recovery >= SRV_FORCE_NO_BACKGROUND))
|| ((trx->mysql_thd || trx->internal)
&& srv_fast_shutdown));
|| srv_fast_shutdown);
#ifdef WITH_WSREP
if (wsrep_is_wsrep_xid(&trx->xid)) {
......
......@@ -131,8 +131,6 @@ trx_init(
trx->will_lock = false;
trx->internal = false;
trx->bulk_insert = false;
ut_d(trx->start_file = 0);
......@@ -369,7 +367,6 @@ void trx_t::free()
ut_ad(!n_mysql_tables_in_use);
ut_ad(!mysql_log_file_name);
ut_ad(!mysql_n_tables_locked);
ut_ad(!internal);
ut_ad(!will_lock);
ut_ad(error_state == DB_SUCCESS);
ut_ad(magic_n == TRX_MAGIC_N);
......@@ -440,7 +437,6 @@ void trx_t::free()
MEM_NOACCESS(&fts_trx, sizeof fts_trx);
MEM_NOACCESS(&fts_next_doc_id, sizeof fts_next_doc_id);
MEM_NOACCESS(&flush_tables, sizeof flush_tables);
MEM_NOACCESS(&internal, sizeof internal);
#ifdef UNIV_DEBUG
MEM_NOACCESS(&start_line, sizeof start_line);
MEM_NOACCESS(&start_file, sizeof start_file);
......@@ -900,7 +896,7 @@ trx_start_low(
trx->auto_commit = thd_trx_is_auto_commit(trx->mysql_thd);
trx->read_only = srv_read_only_mode
|| (!trx->dict_operation && !trx->internal
|| (!trx->dict_operation
&& thd_trx_is_read_only(trx->mysql_thd));
if (!trx->auto_commit) {
......@@ -2090,48 +2086,24 @@ trx_start_if_not_started_low(
ut_error;
}
/*************************************************************//**
Starts a transaction for internal processing. */
void
trx_start_internal_low(
/*===================*/
trx_t* trx) /*!< in/out: transaction */
{
/* Ensure it is not flagged as an auto-commit-non-locking
transaction. */
trx->will_lock = true;
trx->internal = true;
trx_start_low(trx, true);
}
/** Starts a read-only transaction for internal processing.
@param[in,out] trx transaction to be started */
void
trx_start_internal_read_only_low(
trx_t* trx)
/**
Start a transaction for internal processing.
@param trx transaction
@param read_write whether writes may be performed */
void trx_start_internal_low(trx_t *trx, bool read_write)
{
/* Ensure it is not flagged as an auto-commit-non-locking
transaction. */
trx->will_lock = true;
trx->internal = true;
trx_start_low(trx, false);
trx->will_lock= true;
trx_start_low(trx, read_write);
}
/** Start a transaction for a DDL operation.
@param trx transaction */
void trx_start_for_ddl_low(trx_t *trx)
{
ut_a(trx->state == TRX_STATE_NOT_STARTED);
/* Flag this transaction as a dictionary operation, so that
the data dictionary will be locked in crash recovery. */
trx->dict_operation= true;
trx_start_internal_low(trx);
trx_start_internal_low(trx, true);
}
/*************************************************************//**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment