summaryrefslogtreecommitdiff
path: root/storage/innobase/include/row0purge.h
diff options
context:
space:
mode:
Diffstat (limited to 'storage/innobase/include/row0purge.h')
-rw-r--r--storage/innobase/include/row0purge.h137
1 files changed, 98 insertions, 39 deletions
diff --git a/storage/innobase/include/row0purge.h b/storage/innobase/include/row0purge.h
index 1505fb9663a..091d80adec5 100644
--- a/storage/innobase/include/row0purge.h
+++ b/storage/innobase/include/row0purge.h
@@ -32,9 +32,11 @@ Created 3/14/1997 Heikki Tuuri
#include "btr0pcur.h"
#include "trx0types.h"
#include "row0types.h"
-#include "ut0vec.h"
#include "row0mysql.h"
+#include "mysqld.h"
+#include <queue>
+class MDL_ticket;
/** Determines if it is possible to remove a secondary index entry.
Removal is possible if the secondary index entry does not refer to any
not delete marked version of a clustered index record where DB_TRX_ID
@@ -79,6 +81,15 @@ row_purge_step(
que_thr_t* thr) /*!< in: query thread */
MY_ATTRIBUTE((nonnull, warn_unused_result));
+/** Info required to purge a record */
+struct trx_purge_rec_t
+{
+ /** Record to purge */
+ trx_undo_rec_t *undo_rec;
+ /** File pointer to undo record */
+ roll_ptr_t roll_ptr;
+};
+
/* Purge node structure */
struct purge_node_t{
@@ -86,7 +97,6 @@ struct purge_node_t{
/*----------------------*/
/* Local storage for this graph node */
roll_ptr_t roll_ptr;/* roll pointer to undo log record */
- ib_vector_t* undo_recs;/*!< Undo recs to purge */
undo_no_t undo_no;/*!< undo number of the record */
@@ -127,21 +137,36 @@ public:
#endif
trx_id_t trx_id; /*!< trx id for this purging record */
- /** Virtual column information about opening of MariaDB table.
- It resets after processing each undo log record. */
- purge_vcol_info_t vcol_info;
+ /** meta-data lock for the table name */
+ MDL_ticket* mdl_ticket;
+
+ /** table id of the previous undo log record */
+ table_id_t last_table_id;
+
+ /** purge thread */
+ THD* purge_thd;
+
+ /** metadata lock holds for this number of undo log recs */
+ int mdl_hold_recs;
+
+ /** Undo recs to purge */
+ std::queue<trx_purge_rec_t> undo_recs;
/** Constructor */
explicit purge_node_t(que_thr_t* parent) :
common(QUE_NODE_PURGE, parent),
- undo_recs(NULL),
unavailable_table_id(0),
+ table(NULL),
heap(mem_heap_create(256)),
#ifdef UNIV_DEBUG
in_progress(false),
#endif
- vcol_info()
- {}
+ mdl_ticket(NULL),
+ last_table_id(0),
+ purge_thd(NULL),
+ mdl_hold_recs(0)
+ {
+ }
#ifdef UNIV_DEBUG
/***********************************************************//**
@@ -154,11 +179,6 @@ public:
bool validate_pcur();
#endif
- /** Whether purge failed to open the maria table for virtual column
- computation.
- @return true if the table failed to open. */
- bool vcol_op_failed() const { return !vcol_info.validate(); }
-
/** Determine if a table should be skipped in purge.
@param[in] table_id table identifier
@return whether to skip the table lookup and processing */
@@ -177,33 +197,72 @@ public:
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;
- }
+ /** Start processing an undo log record. */
+ void start()
+ {
+ ut_ad(in_progress);
+ DBUG_ASSERT(common.type == QUE_NODE_PURGE);
- /** 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;
- }
+ row= nullptr;
+ ref= nullptr;
+ index= nullptr;
+ update= nullptr;
+ found_clust= FALSE;
+ rec_type= ULINT_UNDEFINED;
+ cmpl_info= ULINT_UNDEFINED;
+ if (!purge_thd)
+ purge_thd= current_thd;
+ }
+
+
+ /** Close the existing table and release the MDL for it. */
+ void close_table()
+ {
+ last_table_id= 0;
+ if (!table)
+ {
+ ut_ad(!mdl_ticket);
+ return;
+ }
+
+ innobase_reset_background_thd(purge_thd);
+ dict_table_close(table, false, false, purge_thd, mdl_ticket);
+ table= nullptr;
+ mdl_ticket= nullptr;
+ }
+
+
+ /** Retail mdl for the table id.
+ @param[in] table_id table id to be processed
+ @return true if retain mdl */
+ bool retain_mdl(table_id_t table_id)
+ {
+ ut_ad(table_id);
+ if (last_table_id == table_id && mdl_hold_recs < 100)
+ {
+ ut_ad(table);
+ mdl_hold_recs++;
+ return true;
+ }
+
+ mdl_hold_recs= 0;
+ close_table();
+ return false;
+ }
+
+
+ /** Reset the state at end
+ @return the query graph parent */
+ que_node_t* end()
+ {
+ DBUG_ASSERT(common.type == QUE_NODE_PURGE);
+ close_table();
+ ut_ad(undo_recs.empty());
+ ut_d(in_progress= false);
+ purge_thd= nullptr;
+ mem_heap_empty(heap);
+ return common.parent;
+ }
};
#endif