Skip to content

Commit

Permalink
Cleanup: Remove mtr_state_t and mtr_t::m_state
Browse files Browse the repository at this point in the history
mtr_t::is_active(), mtr_t::is_committed(): Make debug-only.
  • Loading branch information
dr-m committed Jan 29, 2020
1 parent c69a862 commit 5defdc3
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 101 deletions.
70 changes: 35 additions & 35 deletions storage/innobase/include/mtr0mtr.h
Expand Up @@ -125,25 +125,22 @@ struct mtr_memo_slot_t {

/** Mini-transaction handle and buffer */
struct mtr_t {
mtr_t() : m_state(MTR_STATE_INIT) {}
/** Start a mini-transaction. */
void start();

/** Start a mini-transaction. */
void start();
/** Commit the mini-transaction. */
void commit();

/** Commit the mini-transaction. */
void commit();
/** Commit a mini-transaction that did not modify any pages,
but generated some redo log on a higher level, such as
MLOG_FILE_NAME records and an optional MLOG_CHECKPOINT marker.
The caller must invoke log_mutex_enter() and log_mutex_exit().
This is to be used at log_checkpoint().
@param checkpoint_lsn the log sequence number of a checkpoint, or 0 */
void commit_files(lsn_t checkpoint_lsn= 0);

/** Commit a mini-transaction that did not modify any pages,
but generated some redo log on a higher level, such as
MLOG_FILE_NAME records and an optional MLOG_CHECKPOINT marker.
The caller must invoke log_mutex_enter() and log_mutex_exit().
This is to be used at log_checkpoint().
@param[in] checkpoint_lsn log checkpoint LSN, or 0 */
void commit_files(lsn_t checkpoint_lsn = 0);

/** Return current size of the buffer.
@return savepoint */
ulint get_savepoint() const {ut_ad(is_active()); return m_memo.size();}
/** @return mini-transaction savepoint (current size of m_memo) */
ulint get_savepoint() const { ut_ad(is_active()); return m_memo.size(); }

/** Release the (index tree) s-latch stored in an mtr memo after a
savepoint.
Expand Down Expand Up @@ -331,10 +328,6 @@ struct mtr_t {
/** @return true if we are inside the change buffer code */
bool is_inside_ibuf() const { return m_inside_ibuf; }

/*
@return true if the mini-transaction is active */
bool is_active() const { return m_state == MTR_STATE_ACTIVE; }

/** Get flush observer
@return flush observer */
FlushObserver* get_flush_observer() const { return m_flush_observer; }
Expand Down Expand Up @@ -383,9 +376,6 @@ struct mtr_t {
/** Print info of an mtr handle. */
void print() const;

/** @return true if the mini-transaction has committed */
bool has_committed() const { return m_state == MTR_STATE_COMMITTED; }

/** @return true if mini-transaction contains modifications. */
bool has_modifications() const { return m_modifications; }

Expand Down Expand Up @@ -485,17 +475,30 @@ struct mtr_t {
byte *log_ptr, uint64_t val)
MY_ATTRIBUTE((nonnull));

/** Prepare to write the mini-transaction log to the redo log buffer.
@return number of bytes to write in finish_write() */
inline ulint prepare_write();
/** Prepare to write the mini-transaction log to the redo log buffer.
@return number of bytes to write in finish_write() */
inline ulint prepare_write();

/** Append the redo log records to the redo log buffer.
@param[in] len number of bytes to write
@return start_lsn */
inline lsn_t finish_write(ulint len);
/** Append the redo log records to the redo log buffer.
@param len number of bytes to write
@return start_lsn */
inline lsn_t finish_write(ulint len);

/** Release the resources */
inline void release_resources();
/** Release the resources */
inline void release_resources();

#ifdef UNIV_DEBUG
public:
/** @return whether the mini-transaction is active */
bool is_active() const { ut_ad(!m_commit || m_start); return m_start; }
/** @return whether the mini-transaction has been committed */
bool has_committed() const { ut_ad(!m_commit || m_start); return m_commit; }
private:
/** whether start() has been called */
bool m_start= false;
/** whether commit() has been called */
bool m_commit= false;
#endif

/** memo stack for locks etc. */
mtr_buf_t m_memo;
Expand Down Expand Up @@ -527,9 +530,6 @@ struct mtr_t {
/** User tablespace that is being modified by the mini-transaction */
fil_space_t* m_user_space;

/** State of the transaction */
mtr_state_t m_state;

/** Flush Observer */
FlushObserver* m_flush_observer;

Expand Down
6 changes: 0 additions & 6 deletions storage/innobase/include/mtr0types.h
Expand Up @@ -272,10 +272,4 @@ enum mtr_memo_type_t {
};
#endif /* !UNIV_CHECKSUM */

enum mtr_state_t {
MTR_STATE_INIT = 0,
MTR_STATE_ACTIVE,
MTR_STATE_COMMITTED
};

#endif /* mtr0types_h */
17 changes: 9 additions & 8 deletions storage/innobase/mtr/mtr0mtr.cc
Expand Up @@ -380,6 +380,9 @@ void mtr_t::start()
{
UNIV_MEM_INVALID(this, sizeof *this);

ut_d(m_start= true);
ut_d(m_commit= false);

new(&m_memo) mtr_buf_t();
new(&m_log) mtr_buf_t();

Expand All @@ -389,24 +392,23 @@ void mtr_t::start()
m_n_log_recs= 0;
m_log_mode= MTR_LOG_ALL;
ut_d(m_user_space_id= TRX_SYS_SPACE);
m_user_space= NULL;
m_state= MTR_STATE_ACTIVE;
m_flush_observer= NULL;
m_user_space= nullptr;
m_flush_observer= nullptr;
m_commit_lsn= 0;
}

/** Release the resources */
inline void mtr_t::release_resources()
{
ut_ad(is_active());
ut_d(m_memo.for_each_block_in_reverse(CIterate<DebugCheck>()));
m_log.erase();
m_memo.erase();
m_state= MTR_STATE_COMMITTED;
ut_d(m_commit= true);
}

/** Commit a mini-transaction. */
void
mtr_t::commit()
void mtr_t::commit()
{
ut_ad(is_active());
ut_ad(!is_inside_ibuf());
Expand All @@ -415,8 +417,7 @@ mtr_t::commit()
ut_ad(!m_modifications || !recv_no_log_write);
ut_ad(!m_modifications || m_log_mode != MTR_LOG_NONE);

if (m_modifications
&& (m_n_log_recs || m_log_mode == MTR_LOG_NO_REDO))
if (m_modifications && (m_n_log_recs || m_log_mode == MTR_LOG_NO_REDO))
{
ut_ad(!srv_read_only_mode || m_log_mode == MTR_LOG_NO_REDO);

Expand Down

0 comments on commit 5defdc3

Please sign in to comment.