Commit 6e767046 authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-18878: Slimmer purge in non-debug builds

purge_node_t::in_progress: Replaces purge_node_t::done.
Only present in debug builds.

purge_node_t::start(): Moved from the start of row_purge_step().

purge_node_t::end(): Replaces row_purge_end().

trx_purge_attach_undo_recs(): Omit a check from non-debug builds.
parent 1ab049e5
...@@ -115,13 +115,16 @@ struct purge_node_t{ ...@@ -115,13 +115,16 @@ struct purge_node_t{
mem_heap_t* heap; /*!< memory heap used as auxiliary storage for mem_heap_t* heap; /*!< memory heap used as auxiliary storage for
row; this must be emptied after a successful row; this must be emptied after a successful
purge of a row */ purge of a row */
ibool found_clust;/* TRUE if the clustered index record ibool found_clust;/*!< whether the clustered index record
determined by ref was found in the clustered determined by ref was found in the clustered
index, and we were able to position pcur on index, and we were able to position pcur on
it */ it */
btr_pcur_t pcur; /*!< persistent cursor used in searching the btr_pcur_t pcur; /*!< persistent cursor used in searching the
clustered index record */ clustered index record */
ibool done; /* Debug flag */ #ifdef UNIV_DEBUG
/** whether the operation is in progress */
bool in_progress;
#endif
trx_id_t trx_id; /*!< trx id for this purging record */ trx_id_t trx_id; /*!< trx id for this purging record */
/** Virtual column information about opening of MariaDB table. /** Virtual column information about opening of MariaDB table.
...@@ -130,8 +133,7 @@ struct purge_node_t{ ...@@ -130,8 +133,7 @@ struct purge_node_t{
/** Constructor */ /** Constructor */
explicit purge_node_t(que_thr_t* parent) : explicit purge_node_t(que_thr_t* parent) :
common(QUE_NODE_PURGE, parent), heap(mem_heap_create(256)), common(QUE_NODE_PURGE, parent), heap(mem_heap_create(256))
done(TRUE)
{} {}
#ifdef UNIV_DEBUG #ifdef UNIV_DEBUG
...@@ -167,6 +169,34 @@ struct purge_node_t{ ...@@ -167,6 +169,34 @@ struct purge_node_t{
unavailable_table_id = id; unavailable_table_id = id;
def_trx_id = limit; def_trx_id = limit;
} }
/** Start processing an undo log record. */
void start()
{
ut_ad(in_progress);
DBUG_ASSERT(common.type == QUE_NODE_PURGE);
table = NULL;
row = NULL;
ref = NULL;
index = NULL;
update = NULL;
found_clust = FALSE;
rec_type = ULINT_UNDEFINED;
cmpl_info = ULINT_UNDEFINED;
}
/** Reset the state at end
@return the query graph parent */
que_node_t* end()
{
DBUG_ASSERT(common.type == QUE_NODE_PURGE);
undo_recs = NULL;
ut_d(in_progress = false);
vcol_info.reset();
mem_heap_empty(heap);
return common.parent;
}
}; };
#endif #endif
...@@ -1176,25 +1176,11 @@ row_purge_end( ...@@ -1176,25 +1176,11 @@ row_purge_end(
/*==========*/ /*==========*/
que_thr_t* thr) /*!< in: query thread */ que_thr_t* thr) /*!< in: query thread */
{ {
purge_node_t* node;
ut_ad(thr); ut_ad(thr);
node = static_cast<purge_node_t*>(thr->run_node); thr->run_node = static_cast<purge_node_t*>(thr->run_node)->end();
ut_ad(que_node_get_type(node) == QUE_NODE_PURGE);
thr->run_node = que_node_get_parent(node);
node->undo_recs = NULL;
node->done = TRUE;
node->vcol_info.reset();
ut_a(thr->run_node != NULL); ut_a(thr->run_node != NULL);
mem_heap_empty(node->heap);
} }
/***********************************************************//** /***********************************************************//**
...@@ -1212,18 +1198,7 @@ row_purge_step( ...@@ -1212,18 +1198,7 @@ row_purge_step(
node = static_cast<purge_node_t*>(thr->run_node); node = static_cast<purge_node_t*>(thr->run_node);
node->table = NULL; node->start();
node->row = NULL;
node->ref = NULL;
node->index = NULL;
node->update = NULL;
node->found_clust = FALSE;
node->rec_type = ULINT_UNDEFINED;
node->cmpl_info = ULINT_UNDEFINED;
ut_a(!node->done);
ut_ad(que_node_get_type(node) == QUE_NODE_PURGE);
if (!(node->undo_recs == NULL || ib_vector_is_empty(node->undo_recs))) { if (!(node->undo_recs == NULL || ib_vector_is_empty(node->undo_recs))) {
trx_purge_rec_t*purge_rec; trx_purge_rec_t*purge_rec;
......
...@@ -1501,7 +1501,7 @@ trx_purge_attach_undo_recs( ...@@ -1501,7 +1501,7 @@ trx_purge_attach_undo_recs(
ulint batch_size) /*!< in: no. of pages to purge */ ulint batch_size) /*!< in: no. of pages to purge */
{ {
que_thr_t* thr; que_thr_t* thr;
ulint i = 0; ulint i;
ulint n_pages_handled = 0; ulint n_pages_handled = 0;
ulint n_thrs = UT_LIST_GET_LEN(purge_sys->query->thrs); ulint n_thrs = UT_LIST_GET_LEN(purge_sys->query->thrs);
...@@ -1509,6 +1509,8 @@ trx_purge_attach_undo_recs( ...@@ -1509,6 +1509,8 @@ trx_purge_attach_undo_recs(
purge_sys->limit = purge_sys->iter; purge_sys->limit = purge_sys->iter;
#ifdef UNIV_DEBUG
i = 0;
/* Debug code to validate some pre-requisites and reset done flag. */ /* Debug code to validate some pre-requisites and reset done flag. */
for (thr = UT_LIST_GET_FIRST(purge_sys->query->thrs); for (thr = UT_LIST_GET_FIRST(purge_sys->query->thrs);
thr != NULL && i < n_purge_threads; thr != NULL && i < n_purge_threads;
...@@ -1519,16 +1521,16 @@ trx_purge_attach_undo_recs( ...@@ -1519,16 +1521,16 @@ trx_purge_attach_undo_recs(
/* Get the purge node. */ /* Get the purge node. */
node = (purge_node_t*) thr->child; node = (purge_node_t*) thr->child;
ut_a(que_node_get_type(node) == QUE_NODE_PURGE); ut_ad(que_node_get_type(node) == QUE_NODE_PURGE);
ut_a(node->undo_recs == NULL); ut_ad(node->undo_recs == NULL);
ut_a(node->done); ut_ad(!node->in_progress);
ut_d(node->in_progress = true);
node->done = FALSE;
} }
/* There should never be fewer nodes than threads, the inverse /* There should never be fewer nodes than threads, the inverse
however is allowed because we only use purge threads as needed. */ however is allowed because we only use purge threads as needed. */
ut_a(i == n_purge_threads); ut_ad(i == n_purge_threads);
#endif
/* 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. */
......
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