Commit 4f3b3047 authored by jan@hundin.mysql.fi's avatar jan@hundin.mysql.fi

This is a code cleanup patch for X/Open XA.

parent fb50b9e6
...@@ -16,7 +16,7 @@ Created 3/26/1996 Heikki Tuuri ...@@ -16,7 +16,7 @@ Created 3/26/1996 Heikki Tuuri
#include "que0types.h" #include "que0types.h"
#include "mem0mem.h" #include "mem0mem.h"
#include "read0types.h" #include "read0types.h"
#include "xa.h" #include "trx0xa.h"
extern ulint trx_n_mysql_transactions; extern ulint trx_n_mysql_transactions;
......
...@@ -14,7 +14,7 @@ Created 3/26/1996 Heikki Tuuri ...@@ -14,7 +14,7 @@ Created 3/26/1996 Heikki Tuuri
#include "mtr0mtr.h" #include "mtr0mtr.h"
#include "trx0sys.h" #include "trx0sys.h"
#include "page0types.h" #include "page0types.h"
#include "xa.h" #include "trx0xa.h"
/*************************************************************************** /***************************************************************************
Builds a roll pointer dulint. */ Builds a roll pointer dulint. */
...@@ -469,7 +469,10 @@ page of an update undo log segment. */ ...@@ -469,7 +469,10 @@ page of an update undo log segment. */
log start, and therefore this is not log start, and therefore this is not
necessarily the same as this log necessarily the same as this log
header end offset */ header end offset */
#define TRX_UNDO_DICT_OPERATION 20 /* TRUE if the transaction is a table #define TRX_UNDO_XID_EXISTS 20 /* TRUE if undo log header includes
X/Open XA transaction identification
XID */
#define TRX_UNDO_DICT_TRANS 21 /* TRUE if the transaction is a table
create, index create, or drop create, index create, or drop
transaction: in recovery transaction: in recovery
the transaction cannot be rolled back the transaction cannot be rolled back
...@@ -492,7 +495,6 @@ page of an update undo log segment. */ ...@@ -492,7 +495,6 @@ page of an update undo log segment. */
#define TRX_UNDO_XA_BQUAL_LEN (TRX_UNDO_XA_TRID_LEN + 4) #define TRX_UNDO_XA_BQUAL_LEN (TRX_UNDO_XA_TRID_LEN + 4)
#define TRX_UNDO_XA_XID (TRX_UNDO_XA_BQUAL_LEN + 4) #define TRX_UNDO_XA_XID (TRX_UNDO_XA_BQUAL_LEN + 4)
#define TRX_UNDO_XA_LEN (TRX_UNDO_XA_XID + XIDDATASIZE) #define TRX_UNDO_XA_LEN (TRX_UNDO_XA_XID + XIDDATASIZE)
#define TRX_UNDO_XA_EXISTS 256
/*-------------------------------------------------------------*/ /*-------------------------------------------------------------*/
#define TRX_UNDO_LOG_HDR_SIZE (TRX_UNDO_XA_LEN) #define TRX_UNDO_LOG_HDR_SIZE (TRX_UNDO_XA_LEN)
......
...@@ -24,7 +24,7 @@ Created 3/26/1996 Heikki Tuuri ...@@ -24,7 +24,7 @@ Created 3/26/1996 Heikki Tuuri
#include "thr0loc.h" #include "thr0loc.h"
#include "btr0sea.h" #include "btr0sea.h"
#include "os0proc.h" #include "os0proc.h"
#include "xa.h" #include "trx0xa.h"
/* Copy of the prototype for innobase_mysql_print_thd: this /* Copy of the prototype for innobase_mysql_print_thd: this
copy MUST be equal to the one in mysql/sql/ha_innodb.cc ! */ copy MUST be equal to the one in mysql/sql/ha_innodb.cc ! */
...@@ -1740,10 +1740,6 @@ trx_prepare_off_kernel( ...@@ -1740,10 +1740,6 @@ trx_prepare_off_kernel(
undo = trx->update_undo; undo = trx->update_undo;
if (undo) { if (undo) {
mutex_enter(&kernel_mutex);
trx->no = trx_sys_get_new_trx_no();
mutex_exit(&kernel_mutex);
/* It is not necessary to obtain trx->undo_mutex here /* It is not necessary to obtain trx->undo_mutex here
because only a single OS thread is allowed to do the because only a single OS thread is allowed to do the
...@@ -1781,11 +1777,6 @@ trx_prepare_off_kernel( ...@@ -1781,11 +1777,6 @@ trx_prepare_off_kernel(
mutex_exit(&kernel_mutex); mutex_exit(&kernel_mutex);
if (trx->insert_undo != NULL) {
trx_undo_insert_cleanup(trx);
}
/* Write the log to the log files AND flush them to disk */ /* Write the log to the log files AND flush them to disk */
/*-------------------------------------*/ /*-------------------------------------*/
...@@ -1860,9 +1851,19 @@ trx_recover_for_mysql( ...@@ -1860,9 +1851,19 @@ trx_recover_for_mysql(
while (trx) { while (trx) {
if (trx->conc_state == TRX_PREPARED) { if (trx->conc_state == TRX_PREPARED) {
xid_list[num_of_transactions] = trx->xid; xid_list[num_of_transactions] = trx->xid;
fprintf(stderr,
"InnoDB: Transaction %lu %lu in prepared state after recovery\n",
(ulong) ut_dulint_get_high(trx->id),
(ulong) ut_dulint_get_low(trx->id));
fprintf(stderr,
"InnoDB: Transaction contains changes to %lu rows\n",
(ulong)ut_conv_dulint_to_longlong(trx->undo_no));
num_of_transactions++; num_of_transactions++;
if ( (uint)num_of_transactions == len ) { if ((uint)num_of_transactions == len ) {
break; break;
} }
} }
......
...@@ -19,7 +19,7 @@ Created 3/26/1996 Heikki Tuuri ...@@ -19,7 +19,7 @@ Created 3/26/1996 Heikki Tuuri
#include "srv0srv.h" #include "srv0srv.h"
#include "trx0rec.h" #include "trx0rec.h"
#include "trx0purge.h" #include "trx0purge.h"
#include "xa.h" #include "trx0xa.h"
/* How should the old versions in the history list be managed? /* How should the old versions in the history list be managed?
---------------------------------------------------------- ----------------------------------------------------------
...@@ -537,18 +537,19 @@ trx_undo_header_create( ...@@ -537,18 +537,19 @@ trx_undo_header_create(
/* If X/Open XID exits in the log header we store a /* If X/Open XID exits in the log header we store a
flag of it in upper byte of dict operation flag. */ flag of it in upper byte of dict operation flag. */
if ( xid == NULL || xid->formatID == -1) { if (xid != NULL || xid->formatID != -1) {
mach_write_to_2(log_hdr + TRX_UNDO_DICT_OPERATION, FALSE); mach_write_to_1(log_hdr + TRX_UNDO_XID_EXISTS, TRUE);
} else { } else {
mach_write_to_2(log_hdr + TRX_UNDO_DICT_OPERATION, mach_write_to_1(log_hdr + TRX_UNDO_XID_EXISTS, FALSE);
TRX_UNDO_XA_EXISTS|FALSE);
} }
mach_write_to_1(log_hdr + TRX_UNDO_DICT_TRANS, FALSE);
mach_write_to_2(log_hdr + TRX_UNDO_NEXT_LOG, 0); mach_write_to_2(log_hdr + TRX_UNDO_NEXT_LOG, 0);
mach_write_to_2(log_hdr + TRX_UNDO_PREV_LOG, prev_log); mach_write_to_2(log_hdr + TRX_UNDO_PREV_LOG, prev_log);
/* Write X/Open XA transaction identification if exists */ /* Write X/Open XA transaction identification if exists */
if ( xid && xid->formatID != -1) {
if (xid && xid->formatID != -1) {
trx_undo_write_xid(log_hdr, xid); trx_undo_write_xid(log_hdr, xid);
} }
...@@ -659,18 +660,18 @@ trx_undo_insert_header_reuse( ...@@ -659,18 +660,18 @@ trx_undo_insert_header_reuse(
mach_write_to_8(log_hdr + TRX_UNDO_TRX_ID, trx_id); mach_write_to_8(log_hdr + TRX_UNDO_TRX_ID, trx_id);
mach_write_to_2(log_hdr + TRX_UNDO_LOG_START, new_free); mach_write_to_2(log_hdr + TRX_UNDO_LOG_START, new_free);
/* If X/Open XID exits in the log header we store a /* If X/Open XID exits in the log header we store it
flag of it in upper byte of dict operation flag and to log header. */
then write the xid. */
if (xid && xid->formatID != -1) {
mach_write_to_1(log_hdr + TRX_UNDO_XID_EXISTS, TRUE);
if ( xid && xid->formatID != -1) {
mach_write_to_2(log_hdr + TRX_UNDO_DICT_OPERATION,
TRX_UNDO_XA_EXISTS|FALSE);
trx_undo_write_xid(log_hdr, xid); trx_undo_write_xid(log_hdr, xid);
} else { } else {
mach_write_to_2(log_hdr + TRX_UNDO_DICT_OPERATION, FALSE); mach_write_to_1(log_hdr + TRX_UNDO_XID_EXISTS, FALSE);
} }
mach_write_to_1(log_hdr + TRX_UNDO_DICT_TRANS, FALSE);
trx_undo_insert_header_reuse_log(undo_page, trx_id, mtr); trx_undo_insert_header_reuse_log(undo_page, trx_id, mtr);
return(free); return(free);
...@@ -1203,8 +1204,8 @@ trx_undo_mem_create_at_db_start( ...@@ -1203,8 +1204,8 @@ trx_undo_mem_create_at_db_start(
page_t* last_page; page_t* last_page;
trx_undo_rec_t* rec; trx_undo_rec_t* rec;
XID xid; XID xid;
ulint dict_op; ibool xid_exists = FALSE;
if (id >= TRX_RSEG_N_SLOTS) { if (id >= TRX_RSEG_N_SLOTS) {
fprintf(stderr, fprintf(stderr,
"InnoDB: Error: undo->id is %lu\n", (ulong) id); "InnoDB: Error: undo->id is %lu\n", (ulong) id);
...@@ -1227,9 +1228,8 @@ trx_undo_mem_create_at_db_start( ...@@ -1227,9 +1228,8 @@ trx_undo_mem_create_at_db_start(
trx_id = mtr_read_dulint(undo_header + TRX_UNDO_TRX_ID, mtr); trx_id = mtr_read_dulint(undo_header + TRX_UNDO_TRX_ID, mtr);
dict_op = mtr_read_ulint( xid_exists = mtr_read_ulint(undo_header + TRX_UNDO_XID_EXISTS,
undo_header + TRX_UNDO_DICT_OPERATION, MLOG_1BYTE, mtr);
MLOG_2BYTES, mtr);
/* Read X/Open XA transaction identification if exists or /* Read X/Open XA transaction identification if exists or
set it to NULL. */ set it to NULL. */
...@@ -1237,7 +1237,7 @@ trx_undo_mem_create_at_db_start( ...@@ -1237,7 +1237,7 @@ trx_undo_mem_create_at_db_start(
memset(&xid, 0, sizeof(xid)); memset(&xid, 0, sizeof(xid));
xid.formatID = -1; xid.formatID = -1;
if (dict_op & TRX_UNDO_XA_EXISTS) { if (xid_exists == TRUE) {
trx_undo_read_xid(undo_header, &xid); trx_undo_read_xid(undo_header, &xid);
} }
...@@ -1248,7 +1248,10 @@ trx_undo_mem_create_at_db_start( ...@@ -1248,7 +1248,10 @@ trx_undo_mem_create_at_db_start(
mutex_exit(&(rseg->mutex)); mutex_exit(&(rseg->mutex));
undo->dict_operation = (dict_op & 1); undo->dict_operation = mtr_read_ulint(
undo_header + TRX_UNDO_DICT_TRANS,
MLOG_1BYTE, mtr);
undo->table_id = mtr_read_dulint(undo_header + TRX_UNDO_TABLE_ID, mtr); undo->table_id = mtr_read_dulint(undo_header + TRX_UNDO_TABLE_ID, mtr);
undo->state = state; undo->state = state;
undo->size = flst_get_len(seg_header + TRX_UNDO_PAGE_LIST, mtr); undo->size = flst_get_len(seg_header + TRX_UNDO_PAGE_LIST, mtr);
...@@ -1391,7 +1394,7 @@ trx_undo_mem_create( ...@@ -1391,7 +1394,7 @@ trx_undo_mem_create(
undo->state = TRX_UNDO_ACTIVE; undo->state = TRX_UNDO_ACTIVE;
undo->del_marks = FALSE; undo->del_marks = FALSE;
undo->trx_id = trx_id; undo->trx_id = trx_id;
undo->xid = *xid; undo->xid = *xid;
undo->dict_operation = FALSE; undo->dict_operation = FALSE;
...@@ -1609,18 +1612,9 @@ trx_undo_mark_as_dict_operation( ...@@ -1609,18 +1612,9 @@ trx_undo_mark_as_dict_operation(
hdr_page = trx_undo_page_get(undo->space, undo->hdr_page_no, mtr); hdr_page = trx_undo_page_get(undo->space, undo->hdr_page_no, mtr);
/* Mark X/Open XA XID if it is not NULL to dict operation bit */ mlog_write_ulint(hdr_page + undo->hdr_offset +
TRX_UNDO_DICT_TRANS,
if ( trx->xid.formatID == -1) { trx->dict_operation, MLOG_1BYTE, mtr);
mlog_write_ulint(hdr_page + undo->hdr_offset +
TRX_UNDO_DICT_OPERATION,
trx->dict_operation, MLOG_2BYTES, mtr);
} else {
mlog_write_ulint(hdr_page + undo->hdr_offset +
TRX_UNDO_DICT_OPERATION,
trx->dict_operation | TRX_UNDO_XA_EXISTS,
MLOG_2BYTES, mtr);
}
mlog_write_dulint(hdr_page + undo->hdr_offset + TRX_UNDO_TABLE_ID, mlog_write_dulint(hdr_page + undo->hdr_offset + TRX_UNDO_TABLE_ID,
trx->table_id, mtr); trx->table_id, mtr);
...@@ -1788,6 +1782,9 @@ trx_undo_set_state_at_prepare( ...@@ -1788,6 +1782,9 @@ trx_undo_set_state_at_prepare(
offset = mach_read_from_2(seg_hdr + TRX_UNDO_LAST_LOG); offset = mach_read_from_2(seg_hdr + TRX_UNDO_LAST_LOG);
undo_header = undo_page + offset; undo_header = undo_page + offset;
mlog_write_ulint(undo_header + TRX_UNDO_XID_EXISTS,
TRUE, MLOG_1BYTE, mtr);
trx_undo_write_xid(undo_header, &undo->xid); trx_undo_write_xid(undo_header, &undo->xid);
return(undo_page); return(undo_page);
} }
......
...@@ -80,7 +80,7 @@ extern "C" { ...@@ -80,7 +80,7 @@ extern "C" {
#include "../innobase/include/fsp0fsp.h" #include "../innobase/include/fsp0fsp.h"
#include "../innobase/include/sync0sync.h" #include "../innobase/include/sync0sync.h"
#include "../innobase/include/fil0fil.h" #include "../innobase/include/fil0fil.h"
#include "../innobase/include/xa.h" #include "../innobase/include/trx0xa.h"
} }
#define HA_INNOBASE_ROWS_IN_TABLE 10000 /* to get optimization right */ #define HA_INNOBASE_ROWS_IN_TABLE 10000 /* to get optimization right */
...@@ -5935,7 +5935,7 @@ int innobase_xa_end( ...@@ -5935,7 +5935,7 @@ int innobase_xa_end(
int i; int i;
XID xid; XID xid;
while(trx_num = innobase_xa_recover(trx_list, trx_num_max)) { while((trx_num = innobase_xa_recover(trx_list, trx_num_max))) {
for(i=0;i < trx_num; i++) { for(i=0;i < trx_num; i++) {
xid = trx_list[i]; xid = trx_list[i];
......
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