diff options
author | jan@hundin.mysql.fi <> | 2005-03-01 08:17:03 +0200 |
---|---|---|
committer | jan@hundin.mysql.fi <> | 2005-03-01 08:17:03 +0200 |
commit | 40d89eea68592ff410491c624dbb51dfdcea2e2e (patch) | |
tree | 86f1e3f4fc1565ef7597f6d0135662c8af203012 /innobase | |
parent | 21ca91aac6ed60571e9ccfe3af02c6bc32acd1f7 (diff) | |
download | mariadb-git-40d89eea68592ff410491c624dbb51dfdcea2e2e.tar.gz |
Fixed XA recovery for InnoDB. Note that XA recovery is still disabled
until it has been comprehensive tested.
Diffstat (limited to 'innobase')
-rw-r--r-- | innobase/log/log0log.c | 26 | ||||
-rw-r--r-- | innobase/trx/trx0roll.c | 12 | ||||
-rw-r--r-- | innobase/trx/trx0trx.c | 28 | ||||
-rw-r--r-- | innobase/trx/trx0undo.c | 14 |
4 files changed, 58 insertions, 22 deletions
diff --git a/innobase/log/log0log.c b/innobase/log/log0log.c index 1ab91b71e8f..5915146b466 100644 --- a/innobase/log/log0log.c +++ b/innobase/log/log0log.c @@ -24,6 +24,32 @@ Created 12/9/1995 Heikki Tuuri #include "trx0sys.h" #include "trx0trx.h" +/* +General philosophy of InnoDB redo-logs: + +1) Every change to a contents of a data page must be done +through mtr, which in mtr_commit() writes log records +to the InnoDB redo log. + +2) Normally these changes are performed using a mlog_write_ulint() +or similar function. + +3) In some page level operations only a code number of a +c-function and its parameters are written to the log to +reduce the size of the log. + + 3a) You should not add parameters to these kind of functions + (e.g. trx_undo_header_create(), trx_undo_insert_header_reuse()) + + 3b) You should not add such functionality which either change + working when compared with the old or are dependent on data + outside of the page. These kind of functions should implement + self-contained page transformation and it should be unchanged + if you don't have very essential reasons to change log + semantics or format. + +*/ + /* Current free limit of space 0; protected by the log sys mutex; 0 means uninitialized */ ulint log_fsp_current_free_limit = 0; diff --git a/innobase/trx/trx0roll.c b/innobase/trx/trx0roll.c index 559c2cb5128..4c68e0a0dd3 100644 --- a/innobase/trx/trx0roll.c +++ b/innobase/trx/trx0roll.c @@ -440,7 +440,17 @@ loop: if ((trx->sess || (trx->conc_state == TRX_NOT_STARTED))) { trx = UT_LIST_GET_NEXT(trx_list, trx); } else if (trx->conc_state == TRX_PREPARED) { - trx->sess = trx_dummy_sess; + + /* Roll back all prepared transactions if + innobase_force_recovery > 0 in my.cnf */ + + if (srv_force_recovery > 0) { + trx->conc_state = TRX_ACTIVE; + break; + } else { + trx->sess = trx_dummy_sess; + trx = UT_LIST_GET_NEXT(trx_list, trx); + } } else { break; } diff --git a/innobase/trx/trx0trx.c b/innobase/trx/trx0trx.c index a33ca4b8ec3..344fe280711 100644 --- a/innobase/trx/trx0trx.c +++ b/innobase/trx/trx0trx.c @@ -435,14 +435,14 @@ trx_lists_init_at_db_start(void) if (undo->state == TRX_UNDO_PREPARED) { - fprintf(stderr, + fprintf(stderr, "InnoDB: Transaction %lu %lu was in the XA prepared state.\n", ut_dulint_get_high(trx->id), ut_dulint_get_low(trx->id)); - /* trx->conc_state = TRX_PREPARED; */ - trx->conc_state = - TRX_ACTIVE; + trx->conc_state = TRX_ACTIVE; + + /* trx->conc_state = TRX_PREPARED;*/ } else { trx->conc_state = TRX_COMMITTED_IN_MEMORY; @@ -498,16 +498,15 @@ trx_lists_init_at_db_start(void) commit or abort decision from MySQL */ if (undo->state == TRX_UNDO_PREPARED) { - - fprintf(stderr, + fprintf(stderr, "InnoDB: Transaction %lu %lu was in the XA prepared state.\n", - ut_dulint_get_high(trx->id), - ut_dulint_get_low(trx->id)); + ut_dulint_get_high(trx->id), + ut_dulint_get_low(trx->id)); - /* trx->conc_state = TRX_PREPARED; */ - trx->conc_state = - TRX_ACTIVE; + trx->conc_state = TRX_ACTIVE; + /* trx->conc_state = + TRX_PREPARED; */ } else { trx->conc_state = TRX_COMMITTED_IN_MEMORY; @@ -1638,10 +1637,13 @@ trx_print( fputs(", not started", f); break; case TRX_ACTIVE: - case TRX_PREPARED: fprintf(f, ", ACTIVE %lu sec", (ulong)difftime(time(NULL), trx->start_time)); break; + case TRX_PREPARED: + fprintf(f, ", ACTIVE (PREPARED) %lu sec", + (ulong)difftime(time(NULL), trx->start_time)); + break; case TRX_COMMITTED_IN_MEMORY: fputs(", COMMITTED IN MEMORY", f); break; @@ -1938,7 +1940,7 @@ trx_get_trx_by_xid( if (xid->gtrid_length == trx->xid.gtrid_length && xid->bqual_length == trx->xid.bqual_length && - memcmp(xid, &trx->xid, + memcmp(xid->data, trx->xid.data, xid->gtrid_length + xid->bqual_length) == 0) { break; diff --git a/innobase/trx/trx0undo.c b/innobase/trx/trx0undo.c index 545e1b77fee..88185973dfc 100644 --- a/innobase/trx/trx0undo.c +++ b/innobase/trx/trx0undo.c @@ -599,11 +599,10 @@ trx_undo_read_xid( Adds the XA XID after an undo log old-style header. */ static void -trx_undo_header_add_xid( -/*====================*/ +trx_undo_header_add_space_for_xid( +/*==============================*/ page_t* undo_page,/* in: undo log segment header page */ trx_ulogf_t* log_hdr,/* in: undo log header */ - XID* xid, /* in: X/Open XA transaction identification */ mtr_t* mtr) /* in: mtr */ { trx_upagef_t* page_hdr; @@ -620,9 +619,8 @@ trx_undo_header_add_xid( new_free = free + (TRX_UNDO_LOG_XA_HDR_SIZE - TRX_UNDO_LOG_OLD_HDR_SIZE); - trx_undo_write_xid(log_hdr, xid, mtr); - /* Now that we added the XID after the header, update the free offset + /* Add space for a XID after the header, update the free offset fields on the undo log page and in the undo log header */ mlog_write_ulint(page_hdr + TRX_UNDO_PAGE_START, new_free, @@ -1532,7 +1530,7 @@ trx_undo_create( offset = trx_undo_header_create(undo_page, trx_id, mtr); - trx_undo_header_add_xid(undo_page, undo_page + offset, xid, mtr); + trx_undo_header_add_space_for_xid(undo_page, undo_page + offset, mtr); undo = trx_undo_mem_create(rseg, id, type, trx_id, xid, page_no, offset); @@ -1599,7 +1597,7 @@ trx_undo_reuse_cached( if (type == TRX_UNDO_INSERT) { offset = trx_undo_insert_header_reuse(undo_page, trx_id, mtr); - trx_undo_header_add_xid(undo_page, undo_page + offset, xid, + trx_undo_header_add_space_for_xid(undo_page, undo_page + offset, mtr); } else { ut_a(mach_read_from_2(undo_page + TRX_UNDO_PAGE_HDR @@ -1607,7 +1605,7 @@ trx_undo_reuse_cached( == TRX_UNDO_UPDATE); offset = trx_undo_header_create(undo_page, trx_id, mtr); - trx_undo_header_add_xid(undo_page, undo_page + offset, xid, + trx_undo_header_add_space_for_xid(undo_page, undo_page + offset, mtr); } |