mariadb/storage/innodb_plugin/include/trx0roll.h
Satya B bf3b0747af Applying InnoDB Plugin 1.0.5 snapshot, part 7
From revisions r5792 to r5864

Detailed revision comments:

r5792 | vasil | 2009-09-09 08:35:58 -0500 (Wed, 09 Sep 2009) | 32 lines
branches/zip:

Fix a bug in manipulating the variable innodb_old_blocks_pct:

for any value assigned it got that value -1, except for 75. When
assigned 75, it got 75.

  mysql> set global innodb_old_blocks_pct=15;
  Query OK, 0 rows affected (0.00 sec)
  
  mysql> show variables like 'innodb_old_blocks_pct';
  +-----------------------+-------+
  | Variable_name         | Value |
  +-----------------------+-------+
  | innodb_old_blocks_pct | 14    | 
  +-----------------------+-------+
  1 row in set (0.00 sec)
  
  mysql> set global innodb_old_blocks_pct=75;
  Query OK, 0 rows affected (0.00 sec)
  
  mysql> show variables like 'innodb_old_blocks_pct';
  +-----------------------+-------+
  | Variable_name         | Value |
  +-----------------------+-------+
  | innodb_old_blocks_pct | 75    | 
  +-----------------------+-------+

After the fix it gets exactly what was assigned.

Approved by:	Marko (via IM)

r5798 | calvin | 2009-09-09 10:28:10 -0500 (Wed, 09 Sep 2009) | 5 lines
branches/zip:

HA_ERR_TOO_MANY_CONCURRENT_TRXS is added in 5.1.38.
But the plugin should still work with previous versions
of MySQL.
r5804 | marko | 2009-09-10 00:29:31 -0500 (Thu, 10 Sep 2009) | 1 line
branches/zip: trx_cleanup_at_db_startup(): Fix a typo in comment.
r5822 | marko | 2009-09-10 05:10:20 -0500 (Thu, 10 Sep 2009) | 1 line
branches/zip: buf_page_release(): De-stutter the function comment.
r5825 | marko | 2009-09-10 05:47:09 -0500 (Thu, 10 Sep 2009) | 20 lines
branches/zip: Reduce mutex contention that was introduced when
addressing Bug #45015 (Issue #316), in r5703.

buf_page_set_accessed_make_young(): New auxiliary function, called by
buf_page_get_zip(), buf_page_get_gen(),
buf_page_optimistic_get_func(). Call ut_time_ms() outside of
buf_pool_mutex. Use cached access_time.

buf_page_set_accessed(): Add the parameter time_ms, so that
ut_time_ms() need not be called while holding buf_pool_mutex.

buf_page_optimistic_get_func(), buf_page_get_known_nowait(): Read
buf_page_t::access_time without holding buf_pool_mutex. This should be
OK, because the field is only used for heuristic purposes.

buf_page_peek_if_too_old(): If buf_pool->freed_page_clock == 0, return
FALSE, so that we will not waste time moving blocks in the LRU list in
the warm-up phase or when the workload fits in the buffer pool.

rb://156 approved by Sunny Bains
r5826 | marko | 2009-09-10 06:29:46 -0500 (Thu, 10 Sep 2009) | 12 lines
branches/zip: Roll back recovered dictionary transactions before
dropping incomplete indexes (Issue #337).

trx_rollback_or_clean_recovered(ibool all): New function, split from
trx_rollback_or_clean_all_recovered().  all==FALSE will only roll back
dictionary transactions.

recv_recovery_from_checkpoint_finish(): Call
trx_rollback_or_clean_recovered(FALSE) before
row_merge_drop_temp_indexes().

rb://158 approved by Sunny Bains
r5858 | vasil | 2009-09-11 12:46:47 -0500 (Fri, 11 Sep 2009) | 4 lines
branches/zip:

Fix the indentation of the closing bracket.

r5863 | vasil | 2009-09-12 02:07:08 -0500 (Sat, 12 Sep 2009) | 10 lines
branches/zip:

Check that pthread_t can indeed be passed to Solaris atomic functions, instead
of assuming that it can be passed if 0 can be assigned to it. It could be that:
* 0 can be assigned, but pthread_t cannot be passed and
* 0 cannot be assigned but pthread_t can be passed

Better to check what we are interested in, not something else and make
assumptions.

r5864 | vasil | 2009-09-12 02:22:55 -0500 (Sat, 12 Sep 2009) | 4 lines
branches/zip:

Include string.h which is needed for memset().
2009-10-08 18:35:59 +05:30

352 lines
13 KiB
C

/*****************************************************************************
Copyright (c) 1996, 2009, Innobase Oy. All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place, Suite 330, Boston, MA 02111-1307 USA
*****************************************************************************/
/**************************************************//**
@file include/trx0roll.h
Transaction rollback
Created 3/26/1996 Heikki Tuuri
*******************************************************/
#ifndef trx0roll_h
#define trx0roll_h
#include "univ.i"
#include "trx0trx.h"
#include "trx0types.h"
#include "mtr0mtr.h"
#include "trx0sys.h"
#define trx_roll_free_all_savepoints(s) trx_roll_savepoints_free((s), NULL)
/*******************************************************************//**
Determines if this transaction is rolling back an incomplete transaction
in crash recovery.
@return TRUE if trx is an incomplete transaction that is being rolled
back in crash recovery */
UNIV_INTERN
ibool
trx_is_recv(
/*========*/
const trx_t* trx); /*!< in: transaction */
/*******************************************************************//**
Returns a transaction savepoint taken at this point in time.
@return savepoint */
UNIV_INTERN
trx_savept_t
trx_savept_take(
/*============*/
trx_t* trx); /*!< in: transaction */
/*******************************************************************//**
Creates an undo number array. */
UNIV_INTERN
trx_undo_arr_t*
trx_undo_arr_create(void);
/*=====================*/
/*******************************************************************//**
Frees an undo number array. */
UNIV_INTERN
void
trx_undo_arr_free(
/*==============*/
trx_undo_arr_t* arr); /*!< in: undo number array */
/*******************************************************************//**
Returns pointer to nth element in an undo number array.
@return pointer to the nth element */
UNIV_INLINE
trx_undo_inf_t*
trx_undo_arr_get_nth_info(
/*======================*/
trx_undo_arr_t* arr, /*!< in: undo number array */
ulint n); /*!< in: position */
/***********************************************************************//**
Tries truncate the undo logs. */
UNIV_INTERN
void
trx_roll_try_truncate(
/*==================*/
trx_t* trx); /*!< in/out: transaction */
/********************************************************************//**
Pops the topmost record when the two undo logs of a transaction are seen
as a single stack of records ordered by their undo numbers. Inserts the
undo number of the popped undo record to the array of currently processed
undo numbers in the transaction. When the query thread finishes processing
of this undo record, it must be released with trx_undo_rec_release.
@return undo log record copied to heap, NULL if none left, or if the
undo number of the top record would be less than the limit */
UNIV_INTERN
trx_undo_rec_t*
trx_roll_pop_top_rec_of_trx(
/*========================*/
trx_t* trx, /*!< in: transaction */
undo_no_t limit, /*!< in: least undo number we need */
roll_ptr_t* roll_ptr,/*!< out: roll pointer to undo record */
mem_heap_t* heap); /*!< in: memory heap where copied */
/********************************************************************//**
Reserves an undo log record for a query thread to undo. This should be
called if the query thread gets the undo log record not using the pop
function above.
@return TRUE if succeeded */
UNIV_INTERN
ibool
trx_undo_rec_reserve(
/*=================*/
trx_t* trx, /*!< in/out: transaction */
undo_no_t undo_no);/*!< in: undo number of the record */
/*******************************************************************//**
Releases a reserved undo record. */
UNIV_INTERN
void
trx_undo_rec_release(
/*=================*/
trx_t* trx, /*!< in/out: transaction */
undo_no_t undo_no);/*!< in: undo number */
/*********************************************************************//**
Starts a rollback operation. */
UNIV_INTERN
void
trx_rollback(
/*=========*/
trx_t* trx, /*!< in: transaction */
trx_sig_t* sig, /*!< in: signal starting the rollback */
que_thr_t** next_thr);/*!< in/out: next query thread to run;
if the value which is passed in is
a pointer to a NULL pointer, then the
calling function can start running
a new query thread */
/*******************************************************************//**
Rollback or clean up any incomplete transactions which were
encountered in crash recovery. If the transaction already was
committed, then we clean up a possible insert undo log. If the
transaction was not yet committed, then we roll it back. */
UNIV_INTERN
void
trx_rollback_or_clean_recovered(
/*============================*/
ibool all); /*!< in: FALSE=roll back dictionary transactions;
TRUE=roll back all non-PREPARED transactions */
/*******************************************************************//**
Rollback or clean up any incomplete transactions which were
encountered in crash recovery. If the transaction already was
committed, then we clean up a possible insert undo log. If the
transaction was not yet committed, then we roll it back.
Note: this is done in a background thread.
@return a dummy parameter */
UNIV_INTERN
os_thread_ret_t
trx_rollback_or_clean_all_recovered(
/*================================*/
void* arg __attribute__((unused)));
/*!< in: a dummy parameter required by
os_thread_create */
/****************************************************************//**
Finishes a transaction rollback. */
UNIV_INTERN
void
trx_finish_rollback_off_kernel(
/*===========================*/
que_t* graph, /*!< in: undo graph which can now be freed */
trx_t* trx, /*!< in: transaction */
que_thr_t** next_thr);/*!< in/out: next query thread to run;
if the value which is passed in is
a pointer to a NULL pointer, then the
calling function can start running
a new query thread; if this parameter is
NULL, it is ignored */
/****************************************************************//**
Builds an undo 'query' graph for a transaction. The actual rollback is
performed by executing this query graph like a query subprocedure call.
The reply about the completion of the rollback will be sent by this
graph.
@return own: the query graph */
UNIV_INTERN
que_t*
trx_roll_graph_build(
/*=================*/
trx_t* trx); /*!< in: trx handle */
/*********************************************************************//**
Creates a rollback command node struct.
@return own: rollback node struct */
UNIV_INTERN
roll_node_t*
roll_node_create(
/*=============*/
mem_heap_t* heap); /*!< in: mem heap where created */
/***********************************************************//**
Performs an execution step for a rollback command node in a query graph.
@return query thread to run next, or NULL */
UNIV_INTERN
que_thr_t*
trx_rollback_step(
/*==============*/
que_thr_t* thr); /*!< in: query thread */
/*******************************************************************//**
Rollback a transaction used in MySQL.
@return error code or DB_SUCCESS */
UNIV_INTERN
int
trx_rollback_for_mysql(
/*===================*/
trx_t* trx); /*!< in: transaction handle */
/*******************************************************************//**
Rollback the latest SQL statement for MySQL.
@return error code or DB_SUCCESS */
UNIV_INTERN
int
trx_rollback_last_sql_stat_for_mysql(
/*=================================*/
trx_t* trx); /*!< in: transaction handle */
/*******************************************************************//**
Rollback a transaction used in MySQL.
@return error code or DB_SUCCESS */
UNIV_INTERN
int
trx_general_rollback_for_mysql(
/*===========================*/
trx_t* trx, /*!< in: transaction handle */
trx_savept_t* savept);/*!< in: pointer to savepoint undo number, if
partial rollback requested, or NULL for
complete rollback */
/*******************************************************************//**
Rolls back a transaction back to a named savepoint. Modifications after the
savepoint are undone but InnoDB does NOT release the corresponding locks
which are stored in memory. If a lock is 'implicit', that is, a new inserted
row holds a lock where the lock information is carried by the trx id stored in
the row, these locks are naturally released in the rollback. Savepoints which
were set after this savepoint are deleted.
@return if no savepoint of the name found then DB_NO_SAVEPOINT,
otherwise DB_SUCCESS */
UNIV_INTERN
ulint
trx_rollback_to_savepoint_for_mysql(
/*================================*/
trx_t* trx, /*!< in: transaction handle */
const char* savepoint_name, /*!< in: savepoint name */
ib_int64_t* mysql_binlog_cache_pos);/*!< out: the MySQL binlog cache
position corresponding to this
savepoint; MySQL needs this
information to remove the
binlog entries of the queries
executed after the savepoint */
/*******************************************************************//**
Creates a named savepoint. If the transaction is not yet started, starts it.
If there is already a savepoint of the same name, this call erases that old
savepoint and replaces it with a new. Savepoints are deleted in a transaction
commit or rollback.
@return always DB_SUCCESS */
UNIV_INTERN
ulint
trx_savepoint_for_mysql(
/*====================*/
trx_t* trx, /*!< in: transaction handle */
const char* savepoint_name, /*!< in: savepoint name */
ib_int64_t binlog_cache_pos); /*!< in: MySQL binlog cache
position corresponding to this
connection at the time of the
savepoint */
/*******************************************************************//**
Releases a named savepoint. Savepoints which
were set after this savepoint are deleted.
@return if no savepoint of the name found then DB_NO_SAVEPOINT,
otherwise DB_SUCCESS */
UNIV_INTERN
ulint
trx_release_savepoint_for_mysql(
/*============================*/
trx_t* trx, /*!< in: transaction handle */
const char* savepoint_name); /*!< in: savepoint name */
/*******************************************************************//**
Frees a single savepoint struct. */
UNIV_INTERN
void
trx_roll_savepoint_free(
/*=====================*/
trx_t* trx, /*!< in: transaction handle */
trx_named_savept_t* savep); /*!< in: savepoint to free */
/*******************************************************************//**
Frees savepoint structs starting from savep, if savep == NULL then
free all savepoints. */
UNIV_INTERN
void
trx_roll_savepoints_free(
/*=====================*/
trx_t* trx, /*!< in: transaction handle */
trx_named_savept_t* savep); /*!< in: free all savepoints > this one;
if this is NULL, free all savepoints
of trx */
/** A cell of trx_undo_arr_struct; used during a rollback and a purge */
struct trx_undo_inf_struct{
trx_id_t trx_no; /*!< transaction number: not defined during
a rollback */
undo_no_t undo_no;/*!< undo number of an undo record */
ibool in_use; /*!< TRUE if the cell is in use */
};
/** During a rollback and a purge, undo numbers of undo records currently being
processed are stored in this array */
struct trx_undo_arr_struct{
ulint n_cells; /*!< number of cells in the array */
ulint n_used; /*!< number of cells currently in use */
trx_undo_inf_t* infos; /*!< the array of undo infos */
mem_heap_t* heap; /*!< memory heap from which allocated */
};
/** Rollback node states */
enum roll_node_state {
ROLL_NODE_SEND = 1, /*!< about to send a rollback signal to
the transaction */
ROLL_NODE_WAIT /*!< rollback signal sent to the transaction,
waiting for completion */
};
/** Rollback command node in a query graph */
struct roll_node_struct{
que_common_t common; /*!< node type: QUE_NODE_ROLLBACK */
enum roll_node_state state; /*!< node execution state */
ibool partial;/*!< TRUE if we want a partial
rollback */
trx_savept_t savept; /*!< savepoint to which to
roll back, in the case of a
partial rollback */
};
/** A savepoint set with SQL's "SAVEPOINT savepoint_id" command */
struct trx_named_savept_struct{
char* name; /*!< savepoint name */
trx_savept_t savept; /*!< the undo number corresponding to
the savepoint */
ib_int64_t mysql_binlog_cache_pos;
/*!< the MySQL binlog cache position
corresponding to this savepoint, not
defined if the MySQL binlogging is not
enabled */
UT_LIST_NODE_T(trx_named_savept_t)
trx_savepoints; /*!< the list of savepoints of a
transaction */
};
#ifndef UNIV_NONINL
#include "trx0roll.ic"
#endif
#endif