Skip to content

Commit 1417839

Browse files
committed
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().
1 parent 9928dbe commit 1417839

File tree

8 files changed

+123
-190
lines changed

8 files changed

+123
-190
lines changed

storage/innobase/include/trx0purge.h

Lines changed: 18 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,6 @@ Created 3/26/1996 Heikki Tuuri
3737
#include "fil0fil.h"
3838
#include "read0types.h"
3939

40-
/** The global data structure coordinating a purge */
41-
extern trx_purge_t* purge_sys;
42-
4340
/** A dummy undo record used as a return value when we have a whole undo log
4441
which needs no purge */
4542
extern trx_undo_rec_t trx_purge_dummy_rec;
@@ -54,12 +51,6 @@ trx_purge_get_log_from_hist(
5451
/*========================*/
5552
fil_addr_t node_addr); /*!< in: file address of the history
5653
list node of the log */
57-
/** Create the global purge system data structure. */
58-
void
59-
trx_purge_sys_create();
60-
/** Free the global purge system data structure. */
61-
void
62-
trx_purge_sys_close();
6354
/************************************************************************
6455
Adds the update undo log as the first log in the history list. Removes the
6556
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. */
216207
struct TrxUndoRsegsIterator {
217208

218209
/** Constructor */
219-
TrxUndoRsegsIterator(trx_purge_t* purge_sys);
210+
TrxUndoRsegsIterator();
220211

221-
/** Sets the next rseg to purge in m_purge_sys.
212+
/** Sets the next rseg to purge in purge_sys.
222213
@return page size of the table for which the log is.
223214
NOTE: if rseg is NULL when this function returns this means that
224215
there are no rollback segments to purge and then the returned page
@@ -230,9 +221,6 @@ struct TrxUndoRsegsIterator {
230221
TrxUndoRsegsIterator(const TrxUndoRsegsIterator&);
231222
TrxUndoRsegsIterator& operator=(const TrxUndoRsegsIterator&);
232223

233-
/** The purge system pointer */
234-
trx_purge_t* m_purge_sys;
235-
236224
/** The current element to process */
237225
TrxUndoRsegs m_trx_undo_rsegs;
238226

@@ -506,13 +494,16 @@ namespace undo {
506494
}; /* namespace undo */
507495

508496
/** The control structure used in the purge operation */
509-
struct trx_purge_t{
497+
class purge_sys_t
498+
{
499+
public:
500+
/** Construct the purge system. */
501+
purge_sys_t();
502+
/** Destruct the purge system. */
503+
~purge_sys_t();
504+
510505
sess_t* sess; /*!< System session running the purge
511506
query */
512-
trx_t* trx; /*!< System transaction running the
513-
purge query: this trx is not in the
514-
trx list of the trx system and it
515-
never ends */
516507
rw_lock_t latch; /*!< The latch protecting the purge
517508
view. A purge operation must acquire an
518509
x-latch here for the instant at which
@@ -522,7 +513,7 @@ struct trx_purge_t{
522513
protects state and running */
523514
os_event_t event; /*!< State signal event;
524515
os_event_set() and os_event_reset()
525-
are protected by trx_purge_t::latch
516+
are protected by purge_sys_t::latch
526517
X-lock */
527518
ulint n_stop; /*!< Counter to track number stops */
528519
volatile bool running; /*!< true, if purge is active,
@@ -534,7 +525,6 @@ struct trx_purge_t{
534525
parallelized purge operation */
535526
ReadView view; /*!< The purge will not remove undo logs
536527
which are >= this view (purge view) */
537-
bool view_active; /*!< true if view is active */
538528
volatile ulint n_submitted; /*!< Count of total tasks submitted
539529
to the task queue */
540530
volatile ulint n_completed; /*!< Count of total tasks completed */
@@ -557,11 +547,8 @@ struct trx_purge_t{
557547
purged already accurately. */
558548
#endif /* UNIV_DEBUG */
559549
/*-----------------------------*/
560-
ibool next_stored; /*!< TRUE if the info of the next record
561-
to purge is stored below: if yes, then
562-
the transaction number and the undo
563-
number of the record are stored in
564-
purge_trx_no and purge_undo_no above */
550+
bool next_stored; /*!< whether rseg holds the next record
551+
to purge */
565552
trx_rseg_t* rseg; /*!< Rollback segment for the next undo
566553
record to purge */
567554
ulint page_no; /*!< Page number for the next undo
@@ -575,11 +562,11 @@ struct trx_purge_t{
575562
ulint hdr_offset; /*!< Header byte offset on the page */
576563

577564

578-
TrxUndoRsegsIterator*
565+
TrxUndoRsegsIterator
579566
rseg_iter; /*!< Iterator to get the next rseg
580567
to process */
581568

582-
purge_pq_t* purge_queue; /*!< Binary min-heap, ordered on
569+
purge_pq_t purge_queue; /*!< Binary min-heap, ordered on
583570
TrxUndoRsegs::trx_no. It is protected
584571
by the pq_mutex */
585572
PQMutex pq_mutex; /*!< Mutex protecting purge_queue */
@@ -588,6 +575,9 @@ struct trx_purge_t{
588575
for truncate. */
589576
};
590577

578+
/** The global data structure coordinating a purge */
579+
extern purge_sys_t* purge_sys;
580+
591581
/** Info required to purge a record */
592582
struct trx_purge_rec_t {
593583
trx_undo_rec_t* undo_rec; /*!< Record to purge */

storage/innobase/include/trx0types.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,6 @@ struct trx_sig_t;
123123
struct trx_rseg_t;
124124
/** Transaction undo log */
125125
struct trx_undo_t;
126-
/** The control structure used in the purge operation */
127-
struct trx_purge_t;
128126
/** Rollback command node in a query graph */
129127
struct roll_node_t;
130128
/** Commit command node in a query graph */

storage/innobase/srv/srv0srv.cc

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1661,12 +1661,8 @@ srv_export_innodb_status(void)
16611661

16621662
#ifdef UNIV_DEBUG
16631663
rw_lock_s_lock(&purge_sys->latch);
1664-
trx_id_t up_limit_id;
1664+
trx_id_t up_limit_id = purge_sys->view.up_limit_id();;
16651665
trx_id_t done_trx_no = purge_sys->done.trx_no;
1666-
1667-
up_limit_id = purge_sys->view_active
1668-
? purge_sys->view.up_limit_id() : 0;
1669-
16701666
rw_lock_s_unlock(&purge_sys->latch);
16711667

16721668
mutex_enter(&trx_sys->mutex);

storage/innobase/srv/srv0start.cc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2857,9 +2857,8 @@ innodb_shutdown()
28572857
trx_sys_file_format_close();
28582858
trx_sys_close();
28592859
}
2860-
if (purge_sys) {
2861-
trx_purge_sys_close();
2862-
}
2860+
UT_DELETE(purge_sys);
2861+
purge_sys = NULL;
28632862
if (buf_dblwr) {
28642863
buf_dblwr_free();
28652864
}

0 commit comments

Comments
 (0)