Commit 7d5f2f84 authored by marko's avatar marko

branches/zip: trx_rollback_or_clean_all_without_sess(): Distinguish

recovered transactions from new ones.  Until r1594, they were distinguished
by trx->sess == NULL.

trx_t: Add the bitfield is_recovered.

trx_lists_init_at_db_start(): Set trx->is_recovered.

trx_create(): Initialize trx->is_recovered = 0.

trx_print(): Display information about trx->is_recovered.

trx_rollback_or_clean_all_without_sess(): Skip new transactions.
Protect all accesses of trx_sys->trx_list with kernel_mutex.

trx_roll_crash_recv_trx, trx_roll_max_undo_no, trx_roll_progress_printed_pct:
Made these variables static.
parent b1d3192f
......@@ -476,6 +476,8 @@ struct trx_struct{
current operation, or an empty
string */
unsigned is_purge:1; /* 0=user transaction, 1=purge */
unsigned is_recovered:1; /* 0=normal transaction,
1=recovered, must be rolled back */
unsigned conc_state:2; /* state of the trx from the point
of view of concurrency control:
TRX_ACTIVE, TRX_COMMITTED_IN_MEMORY,
......
......@@ -31,14 +31,14 @@ Created 3/26/1996 Heikki Tuuri
#define TRX_ROLL_TRUNC_THRESHOLD 1
/* In crash recovery, the current trx to be rolled back */
trx_t* trx_roll_crash_recv_trx = NULL;
static trx_t* trx_roll_crash_recv_trx = NULL;
/* In crash recovery we set this to the undo n:o of the current trx to be
rolled back. Then we can print how many % the rollback has progressed. */
ib_longlong trx_roll_max_undo_no;
static ib_longlong trx_roll_max_undo_no;
/* Auxiliary variable which tells the previous progress % we printed */
ulint trx_roll_progress_printed_pct;
static ulint trx_roll_progress_printed_pct;
/***********************************************************************
Rollback a transaction used in MySQL. */
......@@ -525,6 +525,8 @@ trx_rollback_or_clean_all_without_sess(
{
trx_t* trx;
mutex_enter(&kernel_mutex);
if (UT_LIST_GET_FIRST(trx_sys->trx_list)) {
fprintf(stderr,
......@@ -534,10 +536,12 @@ trx_rollback_or_clean_all_without_sess(
goto leave_function;
}
loop:
mutex_enter(&kernel_mutex);
for (trx = UT_LIST_GET_FIRST(trx_sys->trx_list); trx;
trx = UT_LIST_GET_NEXT(trx_list, trx)) {
if (!trx->is_recovered) {
continue;
}
switch (trx->conc_state) {
case TRX_NOT_STARTED:
case TRX_PREPARED:
......@@ -559,13 +563,13 @@ trx_rollback_or_clean_all_without_sess(
}
}
mutex_exit(&kernel_mutex);
ut_print_timestamp(stderr);
fprintf(stderr,
" InnoDB: Rollback of non-prepared transactions completed\n");
leave_function:
mutex_exit(&kernel_mutex);
/* We count the number of threads in os_thread_exit(). A created
thread should always use that to exit and not use return() to exit. */
......
......@@ -81,6 +81,7 @@ trx_create(
trx->op_info = "";
trx->is_purge = 0;
trx->is_recovered = 0;
trx->conc_state = TRX_NOT_STARTED;
trx->start_time = time(NULL);
......@@ -413,6 +414,7 @@ trx_lists_init_at_db_start(void)
trx = trx_create(trx_dummy_sess);
trx->is_recovered = TRUE;
trx->id = undo->trx_id;
trx->xid = undo->xid;
trx->insert_undo = undo;
......@@ -492,6 +494,7 @@ trx_lists_init_at_db_start(void)
if (NULL == trx) {
trx = trx_create(trx_dummy_sess);
trx->is_recovered = TRUE;
trx->id = undo->trx_id;
trx->xid = undo->xid;
......@@ -1635,6 +1638,10 @@ trx_print(
fputs(trx->op_info, f);
}
if (trx->is_recovered) {
fputs(" recovered trx", f);
}
if (trx->is_purge) {
fputs(" purge trx", f);
}
......
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