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

Simplify TrxUndoRsegs

Construct directly from trx_rseg_t&.
push_back(), size(): Remove.
parent d4187bdc
......@@ -27,14 +27,8 @@ Created 3/26/1996 Heikki Tuuri
#ifndef trx0purge_h
#define trx0purge_h
#include "univ.i"
#include "trx0types.h"
#include "mtr0mtr.h"
#include "trx0sys.h"
#include "trx0rseg.h"
#include "que0types.h"
#include "page0page.h"
#include "fil0fil.h"
#include "read0types.h"
/** A dummy undo record used as a return value when we have a whole undo log
which needs no purge */
......@@ -105,14 +99,14 @@ class TrxUndoRsegs {
typedef trx_rsegs_t::iterator iterator;
/** Default constructor */
TrxUndoRsegs() : m_trx_no() { }
TrxUndoRsegs(trx_id_t trx_no = 0) : m_trx_no(trx_no) {}
explicit TrxUndoRsegs(trx_id_t trx_no)
:
m_trx_no(trx_no)
{
// Do nothing
}
/** Constructor */
TrxUndoRsegs(trx_rseg_t& rseg)
: m_trx_no(rseg.last_trx_no), m_rsegs(1, &rseg) {}
/** Constructor */
TrxUndoRsegs(trx_id_t trx_no, trx_rseg_t& rseg)
: m_trx_no(trx_no), m_rsegs(1, &rseg) {}
/** Get transaction number
@return trx_id_t - get transaction number. */
......@@ -121,40 +115,10 @@ class TrxUndoRsegs {
return(m_trx_no);
}
/** Add rollback segment.
@param rseg rollback segment to add. */
void push_back(trx_rseg_t* rseg)
{
m_rsegs.push_back(rseg);
}
/** Erase the element pointed by given iterator.
@param[in] iterator iterator */
void erase(iterator& it)
{
m_rsegs.erase(it);
}
/** Number of registered rsegs.
@return size of rseg list. */
ulint size() const
{
return(m_rsegs.size());
}
/**
@return an iterator to the first element */
iterator begin()
{
return(m_rsegs.begin());
}
/**
@return an iterator to the end */
iterator end()
{
return(m_rsegs.end());
}
bool empty() const { return m_rsegs.empty(); }
void erase(iterator& it) { m_rsegs.erase(it); }
iterator begin() { return(m_rsegs.begin()); }
iterator end() { return(m_rsegs.end()); }
/** Append rollback segments from referred instance to current
instance. */
......@@ -176,10 +140,6 @@ class TrxUndoRsegs {
return(lhs.m_trx_no > rhs.m_trx_no);
}
/** Compiler defined copy-constructor/assignment operator
should be fine given that there is no reference to a memory
object outside scope of class object.*/
private:
/** The rollback segments transaction number. */
trx_id_t m_trx_no;
......@@ -202,7 +162,7 @@ struct TrxUndoRsegsIterator {
/** Sets the next rseg to purge in purge_sys.
@return whether anything is to be purged */
bool set_next();
inline bool set_next();
private:
// Disable copying
......
......@@ -35,7 +35,6 @@ Created 3/26/1996 Heikki Tuuri
#include "mem0mem.h"
#include "mtr0mtr.h"
#include "ut0byte.h"
#include "mem0mem.h"
#include "ut0lst.h"
#include "read0types.h"
#include "page0types.h"
......
......@@ -64,7 +64,7 @@ my_bool srv_purge_view_update_only_debug;
#endif /* UNIV_DEBUG */
/** Sentinel value */
const TrxUndoRsegs TrxUndoRsegsIterator::NullElement(UINT64_UNDEFINED);
const TrxUndoRsegs TrxUndoRsegsIterator::NullElement(TRX_ID_MAX);
/** Constructor */
TrxUndoRsegsIterator::TrxUndoRsegsIterator()
......@@ -110,7 +110,7 @@ TrxUndoRsegsIterator::set_next()
while (!purge_queue.empty()) {
if (m_trx_undo_rsegs.get_trx_no() == UINT64_UNDEFINED) {
if (m_trx_undo_rsegs.get_trx_no() == TRX_ID_MAX) {
m_trx_undo_rsegs = purge_queue.top();
} else if (purge_queue.top().get_trx_no() ==
m_trx_undo_rsegs.get_trx_no()) {
......@@ -903,10 +903,7 @@ trx_purge_cleanse_purge_queue(
}
}
if (it->size()) {
/* size != 0 suggest that there exist other rsegs that
needs processing so add this element to purge queue.
Note: Other rseg could be non-redo rsegs. */
if (!it->empty()) {
purge_sys->purge_queue.push(*it);
}
}
......@@ -1174,9 +1171,6 @@ trx_purge_rseg_get_next_history_log(
rseg->last_trx_no = trx_no;
rseg->needs_purge = purge != 0;
TrxUndoRsegs elem(rseg->last_trx_no);
elem.push_back(rseg);
/* Purge can also produce events, however these are already ordered
in the rollback segment and any user generated event will be greater
than the events that Purge produces. ie. Purge can never produce
......@@ -1184,7 +1178,7 @@ trx_purge_rseg_get_next_history_log(
mutex_enter(&purge_sys->pq_mutex);
purge_sys->purge_queue.push(elem);
purge_sys->purge_queue.push(*rseg);
mutex_exit(&purge_sys->pq_mutex);
......
......@@ -479,15 +479,11 @@ trx_rseg_mem_restore(
ut_ad(purge <= 1);
rseg->needs_purge = purge != 0;
TrxUndoRsegs elem(rseg->last_trx_no);
elem.push_back(rseg);
if (rseg->last_page_no != FIL_NULL) {
/* There is no need to cover this operation by the purge
mutex because we are still bootstrapping. */
purge_sys->purge_queue.push(elem);
purge_sys->purge_queue.push(*rseg);
}
}
}
......
......@@ -1224,15 +1224,12 @@ trx_serialise(trx_t* trx)
trx_sys.assign_new_trx_no(trx);
/* If the rollack segment is not empty then the
/* If the rollback segment is not empty then the
new trx_t::no can't be less than any trx_t::no
already in the rollback segment. User threads only
produce events when a rollback segment is empty. */
if (rseg->last_page_no == FIL_NULL) {
TrxUndoRsegs elem(trx->no);
elem.push_back(rseg);
purge_sys->purge_queue.push(elem);
purge_sys->purge_queue.push(TrxUndoRsegs(trx->no, *rseg));
mutex_exit(&purge_sys->pq_mutex);
}
}
......
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