Commit 9bb5d9fe authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-32050: Clean up log parsing

purge_node_t, undo_node_t: Change the type of rec_type and cmpl_info
to byte, because this data is being extracted from a single byte.

UndoRecApplier: Change type and cmpl_info to be of type byte, and
move them next to the 16-bit offset field to minimize alignment bloat.

row_purge_parse_undo_rec(): Remove some redundant code. Purge will
be started by innodb_ddl_recovery_done(), at which point all
necessary subsystems will have been initialized.

trx_purge_rec_t::undo_rec: Point to const.

Reviewed by: Vladislav Lesin
parent ea42c4ba
...@@ -84,7 +84,7 @@ row_purge_step( ...@@ -84,7 +84,7 @@ row_purge_step(
struct trx_purge_rec_t struct trx_purge_rec_t
{ {
/** Record to purge */ /** Record to purge */
trx_undo_rec_t *undo_rec; const trx_undo_rec_t *undo_rec;
/** File pointer to undo record */ /** File pointer to undo record */
roll_ptr_t roll_ptr; roll_ptr_t roll_ptr;
}; };
...@@ -99,8 +99,9 @@ struct purge_node_t{ ...@@ -99,8 +99,9 @@ struct purge_node_t{
undo_no_t undo_no;/*!< undo number of the record */ undo_no_t undo_no;/*!< undo number of the record */
ulint rec_type;/*!< undo log record type: TRX_UNDO_INSERT_REC, byte rec_type;/*!< undo log record type: TRX_UNDO_INSERT_REC,
... */ ... */
byte cmpl_info;/* compiler analysis info of an update */
private: private:
/** latest unavailable table ID (do not bother looking up again) */ /** latest unavailable table ID (do not bother looking up again) */
table_id_t unavailable_table_id; table_id_t unavailable_table_id;
...@@ -110,8 +111,6 @@ struct purge_node_t{ ...@@ -110,8 +111,6 @@ struct purge_node_t{
public: public:
dict_table_t* table; /*!< table where purge is done */ dict_table_t* table; /*!< table where purge is done */
ulint cmpl_info;/* compiler analysis info of an update */
upd_t* update; /*!< update vector for a clustered index upd_t* update; /*!< update vector for a clustered index
record */ record */
const dtuple_t* ref; /*!< NULL, or row reference to the next row to const dtuple_t* ref; /*!< NULL, or row reference to the next row to
......
...@@ -86,7 +86,7 @@ struct undo_node_t{ ...@@ -86,7 +86,7 @@ struct undo_node_t{
roll_ptr_t roll_ptr;/*!< roll pointer to undo log record */ roll_ptr_t roll_ptr;/*!< roll pointer to undo log record */
trx_undo_rec_t* undo_rec;/*!< undo log record */ trx_undo_rec_t* undo_rec;/*!< undo log record */
undo_no_t undo_no;/*!< undo number of the record */ undo_no_t undo_no;/*!< undo number of the record */
ulint rec_type;/*!< undo log record type: TRX_UNDO_INSERT_REC, byte rec_type;/*!< undo log record type: TRX_UNDO_INSERT_REC,
... */ ... */
trx_id_t new_trx_id; /*!< trx id to restore to clustered index trx_id_t new_trx_id; /*!< trx id to restore to clustered index
record */ record */
......
...@@ -74,9 +74,9 @@ const byte* ...@@ -74,9 +74,9 @@ const byte*
trx_undo_rec_get_pars( trx_undo_rec_get_pars(
/*==================*/ /*==================*/
const trx_undo_rec_t* undo_rec, /*!< in: undo log record */ const trx_undo_rec_t* undo_rec, /*!< in: undo log record */
ulint* type, /*!< out: undo record type: byte* type, /*!< out: undo record type:
TRX_UNDO_INSERT_REC, ... */ TRX_UNDO_INSERT_REC, ... */
ulint* cmpl_info, /*!< out: compiler info, relevant only byte* cmpl_info, /*!< out: compiler info, relevant only
for update type records */ for update type records */
bool* updated_extern, /*!< out: true if we updated an bool* updated_extern, /*!< out: true if we updated an
externally stored fild */ externally stored fild */
......
...@@ -310,14 +310,14 @@ class UndorecApplier ...@@ -310,14 +310,14 @@ class UndorecApplier
page_id_t page_id; page_id_t page_id;
/** Undo log record pointer */ /** Undo log record pointer */
const trx_undo_rec_t *undo_rec; const trx_undo_rec_t *undo_rec;
/** Undo log record type */
byte type;
/** compiler information */
byte cmpl_info;
/** Offset of the undo log record within the block */ /** Offset of the undo log record within the block */
uint16_t offset; uint16_t offset;
/** Transaction id of the undo log */ /** Transaction id of the undo log */
const trx_id_t trx_id; const trx_id_t trx_id;
/** Undo log record type */
ulint type;
/** compiler information */
ulint cmpl_info;
/** Update vector */ /** Update vector */
upd_t *update; upd_t *update;
/** memory heap which can be used to build previous version of /** memory heap which can be used to build previous version of
......
...@@ -48,7 +48,6 @@ Created 3/14/1997 Heikki Tuuri ...@@ -48,7 +48,6 @@ Created 3/14/1997 Heikki Tuuri
#include "ha_innodb.h" #include "ha_innodb.h"
#include "fil0fil.h" #include "fil0fil.h"
#include "debug_sync.h" #include "debug_sync.h"
#include <mysql/service_thd_mdl.h>
/************************************************************************* /*************************************************************************
IMPORTANT NOTE: Any operation that generates redo MUST check that there IMPORTANT NOTE: Any operation that generates redo MUST check that there
...@@ -748,7 +747,7 @@ row_purge_upd_exist_or_extern_func( ...@@ -748,7 +747,7 @@ row_purge_upd_exist_or_extern_func(
const que_thr_t*thr, /*!< in: query thread */ const que_thr_t*thr, /*!< in: query thread */
#endif /* UNIV_DEBUG */ #endif /* UNIV_DEBUG */
purge_node_t* node, /*!< in: row purge node */ purge_node_t* node, /*!< in: row purge node */
trx_undo_rec_t* undo_rec) /*!< in: record to purge */ const trx_undo_rec_t* undo_rec) /*!< in: record to purge */
{ {
mem_heap_t* heap; mem_heap_t* heap;
...@@ -1023,7 +1022,7 @@ static ...@@ -1023,7 +1022,7 @@ static
bool bool
row_purge_parse_undo_rec( row_purge_parse_undo_rec(
purge_node_t* node, purge_node_t* node,
trx_undo_rec_t* undo_rec, const trx_undo_rec_t* undo_rec,
que_thr_t* thr, que_thr_t* thr,
bool* updated_extern) bool* updated_extern)
{ {
...@@ -1032,7 +1031,7 @@ row_purge_parse_undo_rec( ...@@ -1032,7 +1031,7 @@ row_purge_parse_undo_rec(
table_id_t table_id; table_id_t table_id;
roll_ptr_t roll_ptr; roll_ptr_t roll_ptr;
byte info_bits; byte info_bits;
ulint type; byte type;
const byte* ptr = trx_undo_rec_get_pars( const byte* ptr = trx_undo_rec_get_pars(
undo_rec, &type, &node->cmpl_info, undo_rec, &type, &node->cmpl_info,
...@@ -1097,27 +1096,6 @@ row_purge_parse_undo_rec( ...@@ -1097,27 +1096,6 @@ row_purge_parse_undo_rec(
already_locked: already_locked:
ut_ad(!node->table->is_temporary()); ut_ad(!node->table->is_temporary());
switch (type) {
case TRX_UNDO_INSERT_METADATA:
case TRX_UNDO_INSERT_REC:
break;
default:
if (!node->table->n_v_cols || node->table->vc_templ
|| !dict_table_has_indexed_v_cols(node->table)) {
break;
}
/* Need server fully up for virtual column computation */
if (!mysqld_server_started) {
node->close_table();
if (srv_shutdown_state > SRV_SHUTDOWN_NONE) {
return(false);
}
std::this_thread::sleep_for(std::chrono::seconds(1));
goto try_again;
}
}
clust_index = dict_table_get_first_index(node->table); clust_index = dict_table_get_first_index(node->table);
if (!clust_index || clust_index->is_corrupted()) { if (!clust_index || clust_index->is_corrupted()) {
...@@ -1133,15 +1111,16 @@ row_purge_parse_undo_rec( ...@@ -1133,15 +1111,16 @@ row_purge_parse_undo_rec(
err_exit: err_exit:
node->close_table(); node->close_table();
node->skip(table_id, trx_id); node->skip(table_id, trx_id);
return(false); return false;
} }
node->last_table_id = table_id; node->last_table_id = table_id;
if (type == TRX_UNDO_INSERT_METADATA) { switch (type) {
case TRX_UNDO_INSERT_METADATA:
node->ref = &trx_undo_metadata; node->ref = &trx_undo_metadata;
return(true); return true;
} else if (type == TRX_UNDO_EMPTY) { case TRX_UNDO_EMPTY:
node->ref = nullptr; node->ref = nullptr;
return true; return true;
} }
...@@ -1180,7 +1159,7 @@ static MY_ATTRIBUTE((nonnull, warn_unused_result)) ...@@ -1180,7 +1159,7 @@ static MY_ATTRIBUTE((nonnull, warn_unused_result))
bool bool
row_purge_record_func( row_purge_record_func(
purge_node_t* node, purge_node_t* node,
trx_undo_rec_t* undo_rec, const trx_undo_rec_t* undo_rec,
#if defined UNIV_DEBUG || defined WITH_WSREP #if defined UNIV_DEBUG || defined WITH_WSREP
const que_thr_t*thr, const que_thr_t*thr,
#endif /* UNIV_DEBUG || WITH_WSREP */ #endif /* UNIV_DEBUG || WITH_WSREP */
...@@ -1251,7 +1230,7 @@ void ...@@ -1251,7 +1230,7 @@ void
row_purge( row_purge(
/*======*/ /*======*/
purge_node_t* node, /*!< in: row purge node */ purge_node_t* node, /*!< in: row purge node */
trx_undo_rec_t* undo_rec, /*!< in: record to purge */ const trx_undo_rec_t* undo_rec, /*!< in: record to purge */
que_thr_t* thr) /*!< in: query thread */ que_thr_t* thr) /*!< in: query thread */
{ {
if (undo_rec != reinterpret_cast<trx_undo_rec_t*>(-1)) { if (undo_rec != reinterpret_cast<trx_undo_rec_t*>(-1)) {
...@@ -1283,9 +1262,9 @@ inline void purge_node_t::start() ...@@ -1283,9 +1262,9 @@ inline void purge_node_t::start()
ref= nullptr; ref= nullptr;
index= nullptr; index= nullptr;
update= nullptr; update= nullptr;
found_clust= FALSE; found_clust= false;
rec_type= ULINT_UNDEFINED; rec_type= 0;
cmpl_info= ULINT_UNDEFINED; cmpl_info= 0;
if (!purge_thd) if (!purge_thd)
purge_thd= current_thd; purge_thd= current_thd;
} }
......
...@@ -386,7 +386,7 @@ static bool row_undo_ins_parse_undo_rec(undo_node_t* node, bool dict_locked) ...@@ -386,7 +386,7 @@ static bool row_undo_ins_parse_undo_rec(undo_node_t* node, bool dict_locked)
const byte* ptr; const byte* ptr;
undo_no_t undo_no; undo_no_t undo_no;
table_id_t table_id; table_id_t table_id;
ulint dummy; byte dummy;
bool dummy_extern; bool dummy_extern;
ut_ad(node->trx->in_rollback); ut_ad(node->trx->in_rollback);
......
...@@ -1081,8 +1081,8 @@ static bool row_undo_mod_parse_undo_rec(undo_node_t* node, bool dict_locked) ...@@ -1081,8 +1081,8 @@ static bool row_undo_mod_parse_undo_rec(undo_node_t* node, bool dict_locked)
trx_id_t trx_id; trx_id_t trx_id;
roll_ptr_t roll_ptr; roll_ptr_t roll_ptr;
byte info_bits; byte info_bits;
ulint type; byte type;
ulint cmpl_info; byte cmpl_info;
bool dummy_extern; bool dummy_extern;
ut_ad(node->trx->in_rollback); ut_ad(node->trx->in_rollback);
......
...@@ -1109,9 +1109,9 @@ trx_purge_attach_undo_recs(ulint n_purge_threads) ...@@ -1109,9 +1109,9 @@ trx_purge_attach_undo_recs(ulint n_purge_threads)
que_thr_t* thr; que_thr_t* thr;
ulint i; ulint i;
ulint n_pages_handled = 0; ulint n_pages_handled = 0;
ulint n_thrs = UT_LIST_GET_LEN(purge_sys.query->thrs);
ut_a(n_purge_threads > 0); ut_a(n_purge_threads > 0);
ut_a(UT_LIST_GET_LEN(purge_sys.query->thrs) >= n_purge_threads);
purge_sys.head = purge_sys.tail; purge_sys.head = purge_sys.tail;
...@@ -1141,7 +1141,6 @@ trx_purge_attach_undo_recs(ulint n_purge_threads) ...@@ -1141,7 +1141,6 @@ trx_purge_attach_undo_recs(ulint n_purge_threads)
/* Fetch and parse the UNDO records. The UNDO records are added /* Fetch and parse the UNDO records. The UNDO records are added
to a per purge node vector. */ to a per purge node vector. */
thr = UT_LIST_GET_FIRST(purge_sys.query->thrs); thr = UT_LIST_GET_FIRST(purge_sys.query->thrs);
ut_a(n_thrs > 0 && thr != NULL);
ut_ad(purge_sys.head <= purge_sys.tail); ut_ad(purge_sys.head <= purge_sys.tail);
...@@ -1151,13 +1150,8 @@ trx_purge_attach_undo_recs(ulint n_purge_threads) ...@@ -1151,13 +1150,8 @@ trx_purge_attach_undo_recs(ulint n_purge_threads)
mem_heap_empty(purge_sys.heap); mem_heap_empty(purge_sys.heap);
while (UNIV_LIKELY(srv_undo_sources) || !srv_fast_shutdown) { while (UNIV_LIKELY(srv_undo_sources) || !srv_fast_shutdown) {
purge_node_t* node;
trx_purge_rec_t purge_rec; trx_purge_rec_t purge_rec;
/* Get the purge node. */
node = (purge_node_t*) thr->child;
ut_a(que_node_get_type(node) == QUE_NODE_PURGE);
/* Track the max {trx_id, undo_no} for truncating the /* Track the max {trx_id, undo_no} for truncating the
UNDO logs once we have purged the records. */ UNDO logs once we have purged the records. */
...@@ -1170,7 +1164,7 @@ trx_purge_attach_undo_recs(ulint n_purge_threads) ...@@ -1170,7 +1164,7 @@ trx_purge_attach_undo_recs(ulint n_purge_threads)
&purge_rec.roll_ptr, &n_pages_handled, &purge_rec.roll_ptr, &n_pages_handled,
purge_sys.heap); purge_sys.heap);
if (purge_rec.undo_rec == NULL) { if (!purge_rec.undo_rec) {
break; break;
} else if (purge_rec.undo_rec } else if (purge_rec.undo_rec
== reinterpret_cast<trx_undo_rec_t*>(-1)) { == reinterpret_cast<trx_undo_rec_t*>(-1)) {
...@@ -1182,9 +1176,7 @@ trx_purge_attach_undo_recs(ulint n_purge_threads) ...@@ -1182,9 +1176,7 @@ trx_purge_attach_undo_recs(ulint n_purge_threads)
purge_node_t *& table_node = table_id_map[table_id]; purge_node_t *& table_node = table_id_map[table_id];
if (table_node) { if (!table_node) {
node = table_node;
} else {
thr = UT_LIST_GET_NEXT(thrs, thr); thr = UT_LIST_GET_NEXT(thrs, thr);
if (!(++i % n_purge_threads)) { if (!(++i % n_purge_threads)) {
...@@ -1192,11 +1184,11 @@ trx_purge_attach_undo_recs(ulint n_purge_threads) ...@@ -1192,11 +1184,11 @@ trx_purge_attach_undo_recs(ulint n_purge_threads)
purge_sys.query->thrs); purge_sys.query->thrs);
} }
ut_a(thr != NULL); table_node = static_cast<purge_node_t*>(thr->child);
table_node = node; ut_a(que_node_get_type(table_node) == QUE_NODE_PURGE);
} }
node->undo_recs.push(purge_rec); table_node->undo_recs.push(purge_rec);
if (n_pages_handled >= srv_purge_batch_size) { if (n_pages_handled >= srv_purge_batch_size) {
break; break;
...@@ -1256,7 +1248,6 @@ Run a purge batch. ...@@ -1256,7 +1248,6 @@ Run a purge batch.
@return number of undo log pages handled in the batch */ @return number of undo log pages handled in the batch */
TRANSACTIONAL_TARGET ulint trx_purge(ulint n_tasks, ulint history_size) TRANSACTIONAL_TARGET ulint trx_purge(ulint n_tasks, ulint history_size)
{ {
que_thr_t* thr = NULL;
ulint n_pages_handled; ulint n_pages_handled;
ut_ad(n_tasks > 0); ut_ad(n_tasks > 0);
...@@ -1290,6 +1281,8 @@ TRANSACTIONAL_TARGET ulint trx_purge(ulint n_tasks, ulint history_size) ...@@ -1290,6 +1281,8 @@ TRANSACTIONAL_TARGET ulint trx_purge(ulint n_tasks, ulint history_size)
srv_dml_needed_delay = delay; srv_dml_needed_delay = delay;
} }
que_thr_t* thr = nullptr;
/* Submit tasks to workers queue if using multi-threaded purge. */ /* Submit tasks to workers queue if using multi-threaded purge. */
for (ulint i = n_tasks; --i; ) { for (ulint i = n_tasks; --i; ) {
thr = que_fork_scheduler_round_robin(purge_sys.query, thr); thr = que_fork_scheduler_round_robin(purge_sys.query, thr);
......
...@@ -484,9 +484,9 @@ const byte* ...@@ -484,9 +484,9 @@ const byte*
trx_undo_rec_get_pars( trx_undo_rec_get_pars(
/*==================*/ /*==================*/
const trx_undo_rec_t* undo_rec, /*!< in: undo log record */ const trx_undo_rec_t* undo_rec, /*!< in: undo log record */
ulint* type, /*!< out: undo record type: byte* type, /*!< out: undo record type:
TRX_UNDO_INSERT_REC, ... */ TRX_UNDO_INSERT_REC, ... */
ulint* cmpl_info, /*!< out: compiler info, relevant only byte* cmpl_info, /*!< out: compiler info, relevant only
for update type records */ for update type records */
bool* updated_extern, /*!< out: true if we updated an bool* updated_extern, /*!< out: true if we updated an
externally stored fild */ externally stored fild */
...@@ -503,7 +503,7 @@ trx_undo_rec_get_pars( ...@@ -503,7 +503,7 @@ trx_undo_rec_get_pars(
*type = type_cmpl & (TRX_UNDO_CMPL_INFO_MULT - 1); *type = type_cmpl & (TRX_UNDO_CMPL_INFO_MULT - 1);
ut_ad(*type >= TRX_UNDO_RENAME_TABLE); ut_ad(*type >= TRX_UNDO_RENAME_TABLE);
ut_ad(*type <= TRX_UNDO_EMPTY); ut_ad(*type <= TRX_UNDO_EMPTY);
*cmpl_info = type_cmpl / TRX_UNDO_CMPL_INFO_MULT; *cmpl_info = byte(type_cmpl / TRX_UNDO_CMPL_INFO_MULT);
*undo_no = mach_read_next_much_compressed(&ptr); *undo_no = mach_read_next_much_compressed(&ptr);
*table_id = mach_read_next_much_compressed(&ptr); *table_id = mach_read_next_much_compressed(&ptr);
...@@ -2153,14 +2153,14 @@ trx_undo_prev_version_build( ...@@ -2153,14 +2153,14 @@ trx_undo_prev_version_build(
{ {
dtuple_t* entry; dtuple_t* entry;
trx_id_t rec_trx_id; trx_id_t rec_trx_id;
ulint type;
undo_no_t undo_no; undo_no_t undo_no;
table_id_t table_id; table_id_t table_id;
trx_id_t trx_id; trx_id_t trx_id;
roll_ptr_t roll_ptr; roll_ptr_t roll_ptr;
upd_t* update; upd_t* update;
byte type;
byte info_bits; byte info_bits;
ulint cmpl_info; byte cmpl_info;
bool dummy_extern; bool dummy_extern;
byte* buf; byte* buf;
......
...@@ -587,10 +587,10 @@ static dberr_t trx_resurrect_table_locks(trx_t *trx, const trx_undo_t &undo) ...@@ -587,10 +587,10 @@ static dberr_t trx_resurrect_table_locks(trx_t *trx, const trx_undo_t &undo)
do do
{ {
ulint type; byte type;
byte cmpl_info;
undo_no_t undo_no; undo_no_t undo_no;
table_id_t table_id; table_id_t table_id;
ulint cmpl_info;
bool updated_extern; bool updated_extern;
if (undo_block != block) if (undo_block != block)
......
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