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

InnoDB purge_sys cleanup.

TrxUndoRsegsIterator::m_purge_sys: Remove. There is only one purge_sys.

purge_sys_t: Renamed from trx_purge_t. Define a constructor and
destructor. Allocate rseg_iter, purge_queue inline.

purge_sys->trx: Remove. Use purge_sys->sess->trx instead.

purge_sys->view_active: Remove. Access to purge_sys->view is always
protected by purge_sys->latch.

trx_purge_sys_create(): Replaced by purge_sys_t::purge_sys_t().

trx_purge_sys_close(): Replaced by purge_sys_t::~purge_sys_t().
parent 9928dbe5
......@@ -37,9 +37,6 @@ Created 3/26/1996 Heikki Tuuri
#include "fil0fil.h"
#include "read0types.h"
/** The global data structure coordinating a purge */
extern trx_purge_t* purge_sys;
/** A dummy undo record used as a return value when we have a whole undo log
which needs no purge */
extern trx_undo_rec_t trx_purge_dummy_rec;
......@@ -54,12 +51,6 @@ trx_purge_get_log_from_hist(
/*========================*/
fil_addr_t node_addr); /*!< in: file address of the history
list node of the log */
/** Create the global purge system data structure. */
void
trx_purge_sys_create();
/** Free the global purge system data structure. */
void
trx_purge_sys_close();
/************************************************************************
Adds the update undo log as the first log in the history list. Removes the
update undo log segment from the rseg slot if it is too big for reuse. */
......@@ -216,9 +207,9 @@ Chooses the rollback segment with the smallest trx_no. */
struct TrxUndoRsegsIterator {
/** Constructor */
TrxUndoRsegsIterator(trx_purge_t* purge_sys);
TrxUndoRsegsIterator();
/** Sets the next rseg to purge in m_purge_sys.
/** Sets the next rseg to purge in purge_sys.
@return page size of the table for which the log is.
NOTE: if rseg is NULL when this function returns this means that
there are no rollback segments to purge and then the returned page
......@@ -230,9 +221,6 @@ struct TrxUndoRsegsIterator {
TrxUndoRsegsIterator(const TrxUndoRsegsIterator&);
TrxUndoRsegsIterator& operator=(const TrxUndoRsegsIterator&);
/** The purge system pointer */
trx_purge_t* m_purge_sys;
/** The current element to process */
TrxUndoRsegs m_trx_undo_rsegs;
......@@ -506,13 +494,16 @@ namespace undo {
}; /* namespace undo */
/** The control structure used in the purge operation */
struct trx_purge_t{
class purge_sys_t
{
public:
/** Construct the purge system. */
purge_sys_t();
/** Destruct the purge system. */
~purge_sys_t();
sess_t* sess; /*!< System session running the purge
query */
trx_t* trx; /*!< System transaction running the
purge query: this trx is not in the
trx list of the trx system and it
never ends */
rw_lock_t latch; /*!< The latch protecting the purge
view. A purge operation must acquire an
x-latch here for the instant at which
......@@ -522,7 +513,7 @@ struct trx_purge_t{
protects state and running */
os_event_t event; /*!< State signal event;
os_event_set() and os_event_reset()
are protected by trx_purge_t::latch
are protected by purge_sys_t::latch
X-lock */
ulint n_stop; /*!< Counter to track number stops */
volatile bool running; /*!< true, if purge is active,
......@@ -534,7 +525,6 @@ struct trx_purge_t{
parallelized purge operation */
ReadView view; /*!< The purge will not remove undo logs
which are >= this view (purge view) */
bool view_active; /*!< true if view is active */
volatile ulint n_submitted; /*!< Count of total tasks submitted
to the task queue */
volatile ulint n_completed; /*!< Count of total tasks completed */
......@@ -557,11 +547,8 @@ struct trx_purge_t{
purged already accurately. */
#endif /* UNIV_DEBUG */
/*-----------------------------*/
ibool next_stored; /*!< TRUE if the info of the next record
to purge is stored below: if yes, then
the transaction number and the undo
number of the record are stored in
purge_trx_no and purge_undo_no above */
bool next_stored; /*!< whether rseg holds the next record
to purge */
trx_rseg_t* rseg; /*!< Rollback segment for the next undo
record to purge */
ulint page_no; /*!< Page number for the next undo
......@@ -575,11 +562,11 @@ struct trx_purge_t{
ulint hdr_offset; /*!< Header byte offset on the page */
TrxUndoRsegsIterator*
TrxUndoRsegsIterator
rseg_iter; /*!< Iterator to get the next rseg
to process */
purge_pq_t* purge_queue; /*!< Binary min-heap, ordered on
purge_pq_t purge_queue; /*!< Binary min-heap, ordered on
TrxUndoRsegs::trx_no. It is protected
by the pq_mutex */
PQMutex pq_mutex; /*!< Mutex protecting purge_queue */
......@@ -588,6 +575,9 @@ struct trx_purge_t{
for truncate. */
};
/** The global data structure coordinating a purge */
extern purge_sys_t* purge_sys;
/** Info required to purge a record */
struct trx_purge_rec_t {
trx_undo_rec_t* undo_rec; /*!< Record to purge */
......
......@@ -123,8 +123,6 @@ struct trx_sig_t;
struct trx_rseg_t;
/** Transaction undo log */
struct trx_undo_t;
/** The control structure used in the purge operation */
struct trx_purge_t;
/** Rollback command node in a query graph */
struct roll_node_t;
/** Commit command node in a query graph */
......
......@@ -1661,12 +1661,8 @@ srv_export_innodb_status(void)
#ifdef UNIV_DEBUG
rw_lock_s_lock(&purge_sys->latch);
trx_id_t up_limit_id;
trx_id_t up_limit_id = purge_sys->view.up_limit_id();;
trx_id_t done_trx_no = purge_sys->done.trx_no;
up_limit_id = purge_sys->view_active
? purge_sys->view.up_limit_id() : 0;
rw_lock_s_unlock(&purge_sys->latch);
mutex_enter(&trx_sys->mutex);
......
......@@ -2857,9 +2857,8 @@ innodb_shutdown()
trx_sys_file_format_close();
trx_sys_close();
}
if (purge_sys) {
trx_purge_sys_close();
}
UT_DELETE(purge_sys);
purge_sys = NULL;
if (buf_dblwr) {
buf_dblwr_free();
}
......
This diff is collapsed.
......@@ -167,7 +167,6 @@ array in the trx system object.
@param[in] space space where the segment is placed
@param[in] page_no page number of the segment header
@param[in] page_size page size
@param[in,out] purge_queue rseg queue
@param[out] rseg_array add rseg reference to this central array
@param[in,out] mtr mini-transaction
@return own: rollback segment object */
......@@ -178,7 +177,6 @@ trx_rseg_mem_create(
ulint space,
ulint page_no,
const page_size_t& page_size,
purge_pq_t* purge_queue,
trx_rseg_t** rseg_array,
mtr_t* mtr)
{
......@@ -253,7 +251,7 @@ trx_rseg_mem_create(
/* There is no need to cover this operation by the purge
mutex because we are still bootstrapping. */
purge_queue->push(elem);
purge_sys->purge_queue.push(elem);
}
} else {
rseg->last_page_no = FIL_NULL;
......@@ -296,7 +294,7 @@ trx_rseg_array_init()
rseg = trx_rseg_mem_create(
i, space, page_no, page_size,
purge_sys->purge_queue, rseg_array, &mtr);
rseg_array, &mtr);
ut_a(rseg->id == i);
} else {
......@@ -365,7 +363,7 @@ trx_rseg_create(
rseg = trx_rseg_mem_create(
slot_no, space_id, page_no, page_size,
purge_sys->purge_queue, rseg_array, &mtr);
rseg_array, &mtr);
}
mtr_commit(&mtr);
......
......@@ -647,8 +647,6 @@ trx_sys_init_at_db_start()
trx_sys_mutex_exit();
trx_sys->mvcc->clone_oldest_view(&purge_sys->view);
purge_sys->view_active = true;
}
/*****************************************************************//**
......
......@@ -1015,7 +1015,11 @@ trx_lists_init_at_db_start()
ut_ad(!srv_was_started);
ut_ad(!purge_sys);
trx_purge_sys_create();
purge_sys = UT_NEW_NOKEY(purge_sys_t());
if (srv_force_recovery < SRV_FORCE_NO_UNDO_LOG_SCAN) {
trx_rseg_array_init();
}
/* Look from the rollback segments if there exist undo logs for
transactions. */
......@@ -1553,7 +1557,7 @@ trx_serialisation_number_get(
trx_sys_mutex_exit();
purge_sys->purge_queue->push(elem);
purge_sys->purge_queue.push(elem);
mutex_exit(&purge_sys->pq_mutex);
} else {
......
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