#include "trx0undo.h"#include "fsp0fsp.h"#include "mach0data.h"#include "trx0rseg.h"#include "trx0trx.h"#include "srv0srv.h"#include "trx0rec.h"#include "trx0purge.h"#include "trx0xa.h"Include dependency graph for trx0undo.c:

Go to the source code of this file.
| ulint trx_undo_add_page | ( | trx_t * | trx, | |
| trx_undo_t * | undo, | |||
| mtr_t * | mtr | |||
| ) |
Definition at line 819 of file trx0undo.c.
References trx_rseg_struct::curr_size, FIL_NULL, fil_space_release_free_extents(), flst_add_last(), fseg_alloc_free_page_general(), fsp_reserve_free_extents(), FSP_UNDO, FSP_UP, trx_undo_struct::hdr_page_no, kernel_mutex, trx_undo_struct::last_page_no, trx_rseg_struct::max_size, trx_rseg_struct::mutex, page_t, trx_struct::rseg, trx_undo_struct::size, trx_undo_struct::space, trx_undo_struct::top_page_no, TRUE, TRX_UNDO_FSEG_HEADER, trx_undo_page_get(), TRX_UNDO_PAGE_HDR, trx_undo_page_init(), TRX_UNDO_PAGE_LIST, TRX_UNDO_PAGE_NODE, TRX_UNDO_SEG_HDR, trx_undo_struct::type, trx_struct::undo_mutex, and ut_ad.
Referenced by trx_undo_report_row_operation().
00821 : page number if success, else 00822 FIL_NULL */ 00823 trx_t* trx, /* in: transaction */ 00824 trx_undo_t* undo, /* in: undo log memory object */ 00825 mtr_t* mtr) /* in: mtr which does not have a latch to any 00826 undo log page; the caller must have reserved 00827 the rollback segment mutex */ 00828 { 00829 page_t* header_page; 00830 page_t* new_page; 00831 trx_rseg_t* rseg; 00832 ulint page_no; 00833 ulint n_reserved; 00834 ibool success; 00835 00836 #ifdef UNIV_SYNC_DEBUG 00837 ut_ad(mutex_own(&(trx->undo_mutex))); 00838 ut_ad(!mutex_own(&kernel_mutex)); 00839 ut_ad(mutex_own(&(trx->rseg->mutex))); 00840 #endif /* UNIV_SYNC_DEBUG */ 00841 00842 rseg = trx->rseg; 00843 00844 if (rseg->curr_size == rseg->max_size) { 00845 00846 return(FIL_NULL); 00847 } 00848 00849 header_page = trx_undo_page_get(undo->space, undo->hdr_page_no, mtr); 00850 00851 success = fsp_reserve_free_extents(&n_reserved, undo->space, 1, 00852 FSP_UNDO, mtr); 00853 if (!success) { 00854 00855 return(FIL_NULL); 00856 } 00857 00858 page_no = fseg_alloc_free_page_general(header_page + TRX_UNDO_SEG_HDR 00859 + TRX_UNDO_FSEG_HEADER, 00860 undo->top_page_no + 1, FSP_UP, 00861 TRUE, mtr); 00862 00863 fil_space_release_free_extents(undo->space, n_reserved); 00864 00865 if (page_no == FIL_NULL) { 00866 00867 /* No space left */ 00868 00869 return(FIL_NULL); 00870 } 00871 00872 undo->last_page_no = page_no; 00873 00874 new_page = trx_undo_page_get(undo->space, page_no, mtr); 00875 00876 trx_undo_page_init(new_page, undo->type, mtr); 00877 00878 flst_add_last(header_page + TRX_UNDO_SEG_HDR + TRX_UNDO_PAGE_LIST, 00879 new_page + TRX_UNDO_PAGE_HDR + TRX_UNDO_PAGE_NODE, mtr); 00880 undo->size++; 00881 rseg->curr_size++; 00882 00883 return(page_no); 00884 }
Here is the call graph for this function:

Here is the caller graph for this function:

| trx_undo_t* trx_undo_assign_undo | ( | trx_t * | trx, | |
| ulint | type | |||
| ) |
Definition at line 1656 of file trx0undo.c.
References trx_struct::dict_operation, trx_struct::id, trx_struct::insert_undo, kernel_mutex, mtr_commit(), mtr_start(), trx_rseg_struct::mutex, mutex_enter, mutex_exit(), NULL, trx_struct::rseg, trx_undo_create(), TRX_UNDO_INSERT, trx_undo_mark_as_dict_operation(), trx_undo_reuse_cached(), trx_struct::undo_mutex, trx_struct::update_undo, ut_ad, UT_LIST_ADD_FIRST, and trx_struct::xid.
Referenced by trx_undo_report_row_operation().
01658 : the undo log, NULL if did not succeed: out of 01659 space */ 01660 trx_t* trx, /* in: transaction */ 01661 ulint type) /* in: TRX_UNDO_INSERT or TRX_UNDO_UPDATE */ 01662 { 01663 trx_rseg_t* rseg; 01664 trx_undo_t* undo; 01665 mtr_t mtr; 01666 01667 ut_ad(trx); 01668 ut_ad(trx->rseg); 01669 01670 rseg = trx->rseg; 01671 01672 #ifdef UNIV_SYNC_DEBUG 01673 ut_ad(mutex_own(&(trx->undo_mutex))); 01674 #endif /* UNIV_SYNC_DEBUG */ 01675 01676 mtr_start(&mtr); 01677 01678 #ifdef UNIV_SYNC_DEBUG 01679 ut_ad(!mutex_own(&kernel_mutex)); 01680 #endif /* UNIV_SYNC_DEBUG */ 01681 mutex_enter(&(rseg->mutex)); 01682 01683 undo = trx_undo_reuse_cached(trx, rseg, type, trx->id, &trx->xid, 01684 &mtr); 01685 if (undo == NULL) { 01686 undo = trx_undo_create(trx, rseg, type, trx->id, &trx->xid, 01687 &mtr); 01688 if (undo == NULL) { 01689 /* Did not succeed */ 01690 01691 mutex_exit(&(rseg->mutex)); 01692 mtr_commit(&mtr); 01693 01694 return(NULL); 01695 } 01696 } 01697 01698 if (type == TRX_UNDO_INSERT) { 01699 UT_LIST_ADD_FIRST(undo_list, rseg->insert_undo_list, undo); 01700 ut_ad(trx->insert_undo == NULL); 01701 trx->insert_undo = undo; 01702 } else { 01703 UT_LIST_ADD_FIRST(undo_list, rseg->update_undo_list, undo); 01704 ut_ad(trx->update_undo == NULL); 01705 trx->update_undo = undo; 01706 } 01707 01708 if (trx->dict_operation) { 01709 trx_undo_mark_as_dict_operation(trx, undo, &mtr); 01710 } 01711 01712 mutex_exit(&(rseg->mutex)); 01713 mtr_commit(&mtr); 01714 01715 return(undo); 01716 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static trx_undo_t* trx_undo_create | ( | trx_t * | trx, | |
| trx_rseg_t * | rseg, | |||
| ulint | type, | |||
| dulint | trx_id, | |||
| XID * | xid, | |||
| mtr_t * | mtr | |||
| ) | [static] |
Definition at line 1482 of file trx0undo.c.
References buf_frame_get_page_no(), trx_rseg_struct::curr_size, id, trx_rseg_struct::max_size, trx_rseg_struct::mutex, NULL, offset, trx_rseg_struct::page_no, page_t, trx_rseg_struct::space, trx_struct::support_xa, trx_rsegf_get(), trx_undo_header_add_space_for_xid(), trx_undo_header_create(), trx_undo_mem_create(), trx_undo_seg_create(), and ut_ad.
Referenced by trx_undo_assign_undo().
01484 : undo log object, NULL if did not 01485 succeed: out of space */ 01486 trx_t* trx, /* in: transaction */ 01487 trx_rseg_t* rseg, /* in: rollback segment memory copy */ 01488 ulint type, /* in: type of the log: TRX_UNDO_INSERT or 01489 TRX_UNDO_UPDATE */ 01490 dulint trx_id, /* in: id of the trx for which the undo log 01491 is created */ 01492 XID* xid, /* in: X/Open transaction identification*/ 01493 mtr_t* mtr) /* in: mtr */ 01494 { 01495 trx_rsegf_t* rseg_header; 01496 ulint page_no; 01497 ulint offset; 01498 ulint id; 01499 trx_undo_t* undo; 01500 page_t* undo_page; 01501 01502 #ifdef UNIV_SYNC_DEBUG 01503 ut_ad(mutex_own(&(rseg->mutex))); 01504 #endif /* UNIV_SYNC_DEBUG */ 01505 01506 if (rseg->curr_size == rseg->max_size) { 01507 01508 return(NULL); 01509 } 01510 01511 rseg->curr_size++; 01512 01513 rseg_header = trx_rsegf_get(rseg->space, rseg->page_no, mtr); 01514 01515 undo_page = trx_undo_seg_create(rseg, rseg_header, type, &id, mtr); 01516 01517 if (undo_page == NULL) { 01518 /* Did not succeed */ 01519 01520 rseg->curr_size--; 01521 01522 return(NULL); 01523 } 01524 01525 page_no = buf_frame_get_page_no(undo_page); 01526 01527 offset = trx_undo_header_create(undo_page, trx_id, mtr); 01528 01529 if (trx->support_xa) { 01530 trx_undo_header_add_space_for_xid(undo_page, 01531 undo_page + offset, mtr); 01532 } 01533 01534 undo = trx_undo_mem_create(rseg, id, type, trx_id, xid, 01535 page_no, offset); 01536 return(undo); 01537 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 745 of file trx0undo.c.
References MLOG_UNDO_HDR_DISCARD, and mlog_write_initial_log_record().
Referenced by trx_undo_discard_latest_update_undo().
00747 : undo log header page */ 00748 mtr_t* mtr) /* in: mtr */ 00749 { 00750 mlog_write_initial_log_record(undo_page, MLOG_UNDO_HDR_DISCARD, mtr); 00751 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 779 of file trx0undo.c.
References free, mach_read_from_2(), mach_write_to_2(), TRX_UNDO_CACHED, trx_undo_discard_latest_log(), TRX_UNDO_LAST_LOG, TRX_UNDO_LOG_START, TRX_UNDO_NEXT_LOG, TRX_UNDO_PAGE_FREE, TRX_UNDO_PAGE_HDR, TRX_UNDO_PAGE_START, TRX_UNDO_PREV_LOG, TRX_UNDO_SEG_HDR, and TRX_UNDO_STATE.
Referenced by trx_undo_parse_discard_latest().
00781 : header page of an undo log of size 1 */ 00782 mtr_t* mtr) /* in: mtr */ 00783 { 00784 trx_usegf_t* seg_hdr; 00785 trx_upagef_t* page_hdr; 00786 trx_ulogf_t* log_hdr; 00787 trx_ulogf_t* prev_log_hdr; 00788 ulint free; 00789 ulint prev_hdr_offset; 00790 00791 seg_hdr = undo_page + TRX_UNDO_SEG_HDR; 00792 page_hdr = undo_page + TRX_UNDO_PAGE_HDR; 00793 00794 free = mach_read_from_2(seg_hdr + TRX_UNDO_LAST_LOG); 00795 log_hdr = undo_page + free; 00796 00797 prev_hdr_offset = mach_read_from_2(log_hdr + TRX_UNDO_PREV_LOG); 00798 00799 if (prev_hdr_offset != 0) { 00800 prev_log_hdr = undo_page + prev_hdr_offset; 00801 00802 mach_write_to_2(page_hdr + TRX_UNDO_PAGE_START, 00803 mach_read_from_2(prev_log_hdr + TRX_UNDO_LOG_START)); 00804 mach_write_to_2(prev_log_hdr + TRX_UNDO_NEXT_LOG, 0); 00805 } 00806 00807 mach_write_to_2(page_hdr + TRX_UNDO_PAGE_FREE, free); 00808 00809 mach_write_to_2(seg_hdr + TRX_UNDO_STATE, TRX_UNDO_CACHED); 00810 mach_write_to_2(seg_hdr + TRX_UNDO_LAST_LOG, prev_hdr_offset); 00811 00812 trx_undo_discard_latest_log(undo_page, mtr); 00813 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static void trx_undo_empty_header_page | ( | ulint | space, | |
| ulint | hdr_page_no, | |||
| ulint | hdr_offset, | |||
| mtr_t * | mtr | |||
| ) | [static] |
Definition at line 977 of file trx0undo.c.
References MLOG_2BYTES, mlog_write_ulint(), page_t, TRX_UNDO_LOG_START, and trx_undo_page_get().
Referenced by trx_undo_truncate_start().
00979 : space */ 00980 ulint hdr_page_no, /* in: header page number */ 00981 ulint hdr_offset, /* in: header offset */ 00982 mtr_t* mtr) /* in: mtr */ 00983 { 00984 page_t* header_page; 00985 trx_ulogf_t* log_hdr; 00986 ulint end; 00987 00988 header_page = trx_undo_page_get(space, hdr_page_no, mtr); 00989 00990 log_hdr = header_page + hdr_offset; 00991 00992 end = trx_undo_page_get_end(header_page, hdr_page_no, hdr_offset); 00993 00994 mlog_write_ulint(log_hdr + TRX_UNDO_LOG_START, end, MLOG_2BYTES, mtr); 00995 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static ulint trx_undo_free_page | ( | trx_rseg_t * | rseg, | |
| ibool | in_history, | |||
| ulint | space, | |||
| ulint | hdr_page_no, | |||
| ulint | page_no, | |||
| mtr_t * | mtr | |||
| ) | [static] |
Definition at line 890 of file trx0undo.c.
References trx_rseg_struct::curr_size, flst_get_last(), flst_remove(), fseg_free_page(), kernel_mutex, MLOG_4BYTES, mlog_write_ulint(), mtr_read_ulint(), trx_rseg_struct::mutex, fil_addr_struct::page, trx_rseg_struct::page_no, page_t, TRX_RSEG_HISTORY_SIZE, trx_rsegf_get(), TRX_UNDO_FSEG_HEADER, trx_undo_page_get(), TRX_UNDO_PAGE_HDR, TRX_UNDO_PAGE_LIST, TRX_UNDO_PAGE_NODE, TRX_UNDO_SEG_HDR, ut_a, and ut_ad.
Referenced by trx_undo_free_page_in_rollback(), and trx_undo_truncate_start().
00892 : last page number in remaining log */ 00893 trx_rseg_t* rseg, /* in: rollback segment */ 00894 ibool in_history, /* in: TRUE if the undo log is in the history 00895 list */ 00896 ulint space, /* in: space */ 00897 ulint hdr_page_no, /* in: header page number */ 00898 ulint page_no, /* in: page number to free: must not be the 00899 header page */ 00900 mtr_t* mtr) /* in: mtr which does not have a latch to any 00901 undo log page; the caller must have reserved 00902 the rollback segment mutex */ 00903 { 00904 page_t* header_page; 00905 page_t* undo_page; 00906 fil_addr_t last_addr; 00907 trx_rsegf_t* rseg_header; 00908 ulint hist_size; 00909 00910 ut_a(hdr_page_no != page_no); 00911 #ifdef UNIV_SYNC_DEBUG 00912 ut_ad(!mutex_own(&kernel_mutex)); 00913 ut_ad(mutex_own(&(rseg->mutex))); 00914 #endif /* UNIV_SYNC_DEBUG */ 00915 00916 undo_page = trx_undo_page_get(space, page_no, mtr); 00917 00918 header_page = trx_undo_page_get(space, hdr_page_no, mtr); 00919 00920 flst_remove(header_page + TRX_UNDO_SEG_HDR + TRX_UNDO_PAGE_LIST, 00921 undo_page + TRX_UNDO_PAGE_HDR + TRX_UNDO_PAGE_NODE, mtr); 00922 00923 fseg_free_page(header_page + TRX_UNDO_SEG_HDR + TRX_UNDO_FSEG_HEADER, 00924 space, page_no, mtr); 00925 00926 last_addr = flst_get_last(header_page + TRX_UNDO_SEG_HDR 00927 + TRX_UNDO_PAGE_LIST, mtr); 00928 rseg->curr_size--; 00929 00930 if (in_history) { 00931 rseg_header = trx_rsegf_get(space, rseg->page_no, mtr); 00932 00933 hist_size = mtr_read_ulint(rseg_header + TRX_RSEG_HISTORY_SIZE, 00934 MLOG_4BYTES, mtr); 00935 ut_ad(hist_size > 0); 00936 mlog_write_ulint(rseg_header + TRX_RSEG_HISTORY_SIZE, 00937 hist_size - 1, MLOG_4BYTES, mtr); 00938 } 00939 00940 return(last_addr.page); 00941 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static void trx_undo_free_page_in_rollback | ( | trx_t *trx | __attribute__((unused)), | |
| trx_undo_t * | undo, | |||
| ulint | page_no, | |||
| mtr_t * | mtr | |||
| ) | [static] |
Definition at line 948 of file trx0undo.c.
References FALSE, trx_undo_struct::hdr_page_no, trx_undo_struct::last_page_no, trx_undo_struct::rseg, trx_undo_struct::size, trx_undo_struct::space, trx_undo_free_page(), and ut_ad.
Referenced by trx_undo_truncate_end().
00950 : transaction */ 00951 trx_undo_t* undo, /* in: undo log memory copy */ 00952 ulint page_no,/* in: page number to free: must not be the 00953 header page */ 00954 mtr_t* mtr) /* in: mtr which does not have a latch to any 00955 undo log page; the caller must have reserved 00956 the rollback segment mutex */ 00957 { 00958 ulint last_page_no; 00959 00960 ut_ad(undo->hdr_page_no != page_no); 00961 #ifdef UNIV_SYNC_DEBUG 00962 ut_ad(mutex_own(&(trx->undo_mutex))); 00963 #endif /* UNIV_SYNC_DEBUG */ 00964 00965 last_page_no = trx_undo_free_page(undo->rseg, FALSE, undo->space, 00966 undo->hdr_page_no, page_no, mtr); 00967 00968 undo->last_page_no = last_page_no; 00969 undo->size--; 00970 }
Here is the call graph for this function:

Here is the caller graph for this function:

| trx_undo_rec_t* trx_undo_get_first_rec | ( | ulint | space, | |
| ulint | page_no, | |||
| ulint | offset, | |||
| ulint | mode, | |||
| mtr_t * | mtr | |||
| ) |
Definition at line 274 of file trx0undo.c.
References page_t, RW_S_LATCH, trx_undo_get_next_rec_from_next_page(), trx_undo_page_get(), trx_undo_page_get_first_rec(), and trx_undo_page_get_s_latched().
Referenced by trx_purge_choose_next_log(), and trx_undo_truncate_start().
00276 : undo log record, the page latched, NULL if 00277 none */ 00278 ulint space, /* in: undo log header space */ 00279 ulint page_no,/* in: undo log header page number */ 00280 ulint offset, /* in: undo log header offset on page */ 00281 ulint mode, /* in: latching mode: RW_S_LATCH or RW_X_LATCH */ 00282 mtr_t* mtr) /* in: mtr */ 00283 { 00284 page_t* undo_page; 00285 trx_undo_rec_t* rec; 00286 00287 if (mode == RW_S_LATCH) { 00288 undo_page = trx_undo_page_get_s_latched(space, page_no, mtr); 00289 } else { 00290 undo_page = trx_undo_page_get(space, page_no, mtr); 00291 } 00292 00293 rec = trx_undo_page_get_first_rec(undo_page, page_no, offset); 00294 00295 if (rec) { 00296 return(rec); 00297 } 00298 00299 return(trx_undo_get_next_rec_from_next_page(undo_page, page_no, offset, 00300 mode, mtr)); 00301 }
Here is the call graph for this function:

Here is the caller graph for this function:

| trx_undo_rec_t* trx_undo_get_next_rec | ( | trx_undo_rec_t * | rec, | |
| ulint | page_no, | |||
| ulint | offset, | |||
| mtr_t * | mtr | |||
| ) |
Definition at line 248 of file trx0undo.c.
References buf_frame_align(), RW_S_LATCH, trx_undo_get_next_rec_from_next_page(), and trx_undo_page_get_next_rec().
Referenced by trx_purge_get_next_rec().
00250 : undo log record, the page s-latched, 00251 NULL if none */ 00252 trx_undo_rec_t* rec, /* in: undo record */ 00253 ulint page_no,/* in: undo log header page number */ 00254 ulint offset, /* in: undo log header offset on page */ 00255 mtr_t* mtr) /* in: mtr */ 00256 { 00257 trx_undo_rec_t* next_rec; 00258 00259 next_rec = trx_undo_page_get_next_rec(rec, page_no, offset); 00260 00261 if (next_rec) { 00262 return(next_rec); 00263 } 00264 00265 return(trx_undo_get_next_rec_from_next_page(buf_frame_align(rec), 00266 page_no, offset, 00267 RW_S_LATCH, mtr)); 00268 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static trx_undo_rec_t* trx_undo_get_next_rec_from_next_page | ( | page_t * | undo_page, | |
| ulint | page_no, | |||
| ulint | offset, | |||
| ulint | mode, | |||
| mtr_t * | mtr | |||
| ) | [static] |
Definition at line 196 of file trx0undo.c.
References buf_frame_get_page_no(), buf_frame_get_space_id(), FIL_NULL, flst_get_next_addr(), mach_read_from_2(), NULL, fil_addr_struct::page, page_t, RW_S_LATCH, RW_X_LATCH, TRX_UNDO_NEXT_LOG, trx_undo_page_get(), trx_undo_page_get_first_rec(), trx_undo_page_get_s_latched(), TRX_UNDO_PAGE_HDR, TRX_UNDO_PAGE_NODE, and ut_ad.
Referenced by trx_undo_get_first_rec(), and trx_undo_get_next_rec().
00198 : undo log record, the page latched, NULL if 00199 none */ 00200 page_t* undo_page, /* in: undo log page */ 00201 ulint page_no,/* in: undo log header page number */ 00202 ulint offset, /* in: undo log header offset on page */ 00203 ulint mode, /* in: latch mode: RW_S_LATCH or RW_X_LATCH */ 00204 mtr_t* mtr) /* in: mtr */ 00205 { 00206 trx_ulogf_t* log_hdr; 00207 ulint next_page_no; 00208 page_t* next_page; 00209 ulint space; 00210 ulint next; 00211 00212 if (page_no == buf_frame_get_page_no(undo_page)) { 00213 00214 log_hdr = undo_page + offset; 00215 next = mach_read_from_2(log_hdr + TRX_UNDO_NEXT_LOG); 00216 00217 if (next != 0) { 00218 00219 return(NULL); 00220 } 00221 } 00222 00223 space = buf_frame_get_space_id(undo_page); 00224 00225 next_page_no = flst_get_next_addr(undo_page + TRX_UNDO_PAGE_HDR 00226 + TRX_UNDO_PAGE_NODE, mtr) 00227 .page; 00228 if (next_page_no == FIL_NULL) { 00229 00230 return(NULL); 00231 } 00232 00233 if (mode == RW_S_LATCH) { 00234 next_page = trx_undo_page_get_s_latched(space, next_page_no, 00235 mtr); 00236 } else { 00237 ut_ad(mode == RW_X_LATCH); 00238 next_page = trx_undo_page_get(space, next_page_no, mtr); 00239 } 00240 00241 return(trx_undo_page_get_first_rec(next_page, page_no, offset)); 00242 }
Here is the call graph for this function:

Here is the caller graph for this function:

| trx_undo_rec_t* trx_undo_get_prev_rec | ( | trx_undo_rec_t * | rec, | |
| ulint | page_no, | |||
| ulint | offset, | |||
| mtr_t * | mtr | |||
| ) |
Definition at line 167 of file trx0undo.c.
References trx_undo_get_prev_rec_from_prev_page(), and trx_undo_page_get_prev_rec().
Referenced by trx_roll_pop_top_rec().
00169 : undo log record, the page s-latched, 00170 NULL if none */ 00171 trx_undo_rec_t* rec, /* in: undo record */ 00172 ulint page_no,/* in: undo log header page number */ 00173 ulint offset, /* in: undo log header offset on page */ 00174 mtr_t* mtr) /* in: mtr */ 00175 { 00176 trx_undo_rec_t* prev_rec; 00177 00178 prev_rec = trx_undo_page_get_prev_rec(rec, page_no, offset); 00179 00180 if (prev_rec) { 00181 00182 return(prev_rec); 00183 } 00184 00185 /* We have to go to the previous undo log page to look for the 00186 previous record */ 00187 00188 return(trx_undo_get_prev_rec_from_prev_page(rec, page_no, offset, 00189 mtr)); 00190 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static trx_undo_rec_t* trx_undo_get_prev_rec_from_prev_page | ( | trx_undo_rec_t * | rec, | |
| ulint | page_no, | |||
| ulint | offset, | |||
| mtr_t * | mtr | |||
| ) | [static] |
Definition at line 132 of file trx0undo.c.
References buf_frame_align(), buf_frame_get_space_id(), FIL_NULL, flst_get_prev_addr(), NULL, fil_addr_struct::page, page_t, trx_undo_page_get_last_rec(), trx_undo_page_get_s_latched(), TRX_UNDO_PAGE_HDR, and TRX_UNDO_PAGE_NODE.
Referenced by trx_undo_get_prev_rec().
00134 : undo log record, the page s-latched, 00135 NULL if none */ 00136 trx_undo_rec_t* rec, /* in: undo record */ 00137 ulint page_no,/* in: undo log header page number */ 00138 ulint offset, /* in: undo log header offset on page */ 00139 mtr_t* mtr) /* in: mtr */ 00140 { 00141 ulint prev_page_no; 00142 page_t* prev_page; 00143 page_t* undo_page; 00144 00145 undo_page = buf_frame_align(rec); 00146 00147 prev_page_no = flst_get_prev_addr(undo_page + TRX_UNDO_PAGE_HDR 00148 + TRX_UNDO_PAGE_NODE, mtr) 00149 .page; 00150 00151 if (prev_page_no == FIL_NULL) { 00152 00153 return(NULL); 00154 } 00155 00156 prev_page = trx_undo_page_get_s_latched( 00157 buf_frame_get_space_id(undo_page), 00158 prev_page_no, mtr); 00159 00160 return(trx_undo_page_get_last_rec(prev_page, page_no, offset)); 00161 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static void trx_undo_header_add_space_for_xid | ( | page_t * | undo_page, | |
| trx_ulogf_t * | log_hdr, | |||
| mtr_t * | mtr | |||
| ) | [static] |
Definition at line 598 of file trx0undo.c.
References free, mach_read_from_2(), MLOG_2BYTES, mlog_write_ulint(), TRX_UNDO_LOG_OLD_HDR_SIZE, TRX_UNDO_LOG_START, TRX_UNDO_LOG_XA_HDR_SIZE, TRX_UNDO_PAGE_FREE, TRX_UNDO_PAGE_HDR, TRX_UNDO_PAGE_START, and ut_a.
Referenced by trx_undo_create(), and trx_undo_reuse_cached().
00600 : undo log segment header page */ 00601 trx_ulogf_t* log_hdr,/* in: undo log header */ 00602 mtr_t* mtr) /* in: mtr */ 00603 { 00604 trx_upagef_t* page_hdr; 00605 ulint free; 00606 ulint new_free; 00607 00608 page_hdr = undo_page + TRX_UNDO_PAGE_HDR; 00609 00610 free = mach_read_from_2(page_hdr + TRX_UNDO_PAGE_FREE); 00611 00612 /* free is now the end offset of the old style undo log header */ 00613 00614 ut_a(free == (ulint)(log_hdr - undo_page) + TRX_UNDO_LOG_OLD_HDR_SIZE); 00615 00616 new_free = free + (TRX_UNDO_LOG_XA_HDR_SIZE 00617 - TRX_UNDO_LOG_OLD_HDR_SIZE); 00618 00619 /* Add space for a XID after the header, update the free offset 00620 fields on the undo log page and in the undo log header */ 00621 00622 mlog_write_ulint(page_hdr + TRX_UNDO_PAGE_START, new_free, 00623 MLOG_2BYTES, mtr); 00624 00625 mlog_write_ulint(page_hdr + TRX_UNDO_PAGE_FREE, new_free, 00626 MLOG_2BYTES, mtr); 00627 00628 mlog_write_ulint(log_hdr + TRX_UNDO_LOG_START, new_free, 00629 MLOG_2BYTES, mtr); 00630 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 486 of file trx0undo.c.
References FALSE, free, mach_read_from_2(), mach_write_to_1(), mach_write_to_2(), mach_write_to_8(), TRUE, TRX_UNDO_ACTIVE, TRX_UNDO_DEL_MARKS, TRX_UNDO_DICT_TRANS, trx_undo_header_create_log(), TRX_UNDO_LAST_LOG, TRX_UNDO_LOG_OLD_HDR_SIZE, TRX_UNDO_LOG_START, TRX_UNDO_LOG_XA_HDR_SIZE, TRX_UNDO_NEXT_LOG, TRX_UNDO_PAGE_FREE, TRX_UNDO_PAGE_HDR, TRX_UNDO_PAGE_START, TRX_UNDO_PREV_LOG, TRX_UNDO_SEG_HDR, TRX_UNDO_STATE, TRX_UNDO_TRX_ID, TRX_UNDO_XID_EXISTS, UNIV_PAGE_SIZE, ut_a, and ut_ad.
Referenced by trx_undo_create(), trx_undo_parse_page_header(), and trx_undo_reuse_cached().
00488 : header byte offset on page */ 00489 page_t* undo_page, /* in: undo log segment header page, 00490 x-latched; it is assumed that there are 00491 TRX_UNDO_LOG_XA_HDR_SIZE bytes free space 00492 on it */ 00493 dulint trx_id, /* in: transaction id */ 00494 mtr_t* mtr) /* in: mtr */ 00495 { 00496 trx_upagef_t* page_hdr; 00497 trx_usegf_t* seg_hdr; 00498 trx_ulogf_t* log_hdr; 00499 trx_ulogf_t* prev_log_hdr; 00500 ulint prev_log; 00501 ulint free; 00502 ulint new_free; 00503 00504 ut_ad(mtr && undo_page); 00505 00506 page_hdr = undo_page + TRX_UNDO_PAGE_HDR; 00507 seg_hdr = undo_page + TRX_UNDO_SEG_HDR; 00508 00509 free = mach_read_from_2(page_hdr + TRX_UNDO_PAGE_FREE); 00510 00511 log_hdr = undo_page + free; 00512 00513 new_free = free + TRX_UNDO_LOG_OLD_HDR_SIZE; 00514 00515 ut_a(free + TRX_UNDO_LOG_XA_HDR_SIZE < UNIV_PAGE_SIZE - 100); 00516 00517 mach_write_to_2(page_hdr + TRX_UNDO_PAGE_START, new_free); 00518 00519 mach_write_to_2(page_hdr + TRX_UNDO_PAGE_FREE, new_free); 00520 00521 mach_write_to_2(seg_hdr + TRX_UNDO_STATE, TRX_UNDO_ACTIVE); 00522 00523 prev_log = mach_read_from_2(seg_hdr + TRX_UNDO_LAST_LOG); 00524 00525 if (prev_log != 0) { 00526 prev_log_hdr = undo_page + prev_log; 00527 00528 mach_write_to_2(prev_log_hdr + TRX_UNDO_NEXT_LOG, free); 00529 } 00530 00531 mach_write_to_2(seg_hdr + TRX_UNDO_LAST_LOG, free); 00532 00533 log_hdr = undo_page + free; 00534 00535 mach_write_to_2(log_hdr + TRX_UNDO_DEL_MARKS, TRUE); 00536 00537 mach_write_to_8(log_hdr + TRX_UNDO_TRX_ID, trx_id); 00538 mach_write_to_2(log_hdr + TRX_UNDO_LOG_START, new_free); 00539 00540 mach_write_to_1(log_hdr + TRX_UNDO_XID_EXISTS, FALSE); 00541 mach_write_to_1(log_hdr + TRX_UNDO_DICT_TRANS, FALSE); 00542 00543 mach_write_to_2(log_hdr + TRX_UNDO_NEXT_LOG, 0); 00544 mach_write_to_2(log_hdr + TRX_UNDO_PREV_LOG, prev_log); 00545 00546 /* Write the log record about the header creation */ 00547 trx_undo_header_create_log(undo_page, trx_id, mtr); 00548 00549 return(free); 00550 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 469 of file trx0undo.c.
References mlog_catenate_dulint_compressed(), MLOG_UNDO_HDR_CREATE, and mlog_write_initial_log_record().
Referenced by trx_undo_header_create().
00471 : undo log header page */ 00472 dulint trx_id, /* in: transaction id */ 00473 mtr_t* mtr) /* in: mtr */ 00474 { 00475 mlog_write_initial_log_record(undo_page, MLOG_UNDO_HDR_CREATE, mtr); 00476 00477 mlog_catenate_dulint_compressed(mtr, trx_id); 00478 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void trx_undo_insert_cleanup | ( | trx_t * | trx | ) |
Definition at line 1862 of file trx0undo.c.
References trx_rseg_struct::curr_size, trx_struct::insert_undo, trx_rseg_struct::mutex, mutex_enter, mutex_exit(), NULL, trx_struct::rseg, trx_undo_struct::size, trx_undo_struct::state, TRX_UNDO_CACHED, trx_undo_mem_free(), trx_undo_seg_free(), TRX_UNDO_TO_FREE, ut_ad, UT_LIST_ADD_FIRST, and UT_LIST_REMOVE.
Referenced by trx_cleanup_at_db_startup(), and trx_commit_off_kernel().
01864 : transaction handle */ 01865 { 01866 trx_undo_t* undo; 01867 trx_rseg_t* rseg; 01868 01869 undo = trx->insert_undo; 01870 ut_ad(undo); 01871 01872 rseg = trx->rseg; 01873 01874 mutex_enter(&(rseg->mutex)); 01875 01876 UT_LIST_REMOVE(undo_list, rseg->insert_undo_list, undo); 01877 trx->insert_undo = NULL; 01878 01879 if (undo->state == TRX_UNDO_CACHED) { 01880 01881 UT_LIST_ADD_FIRST(undo_list, rseg->insert_undo_cached, undo); 01882 } else { 01883 ut_ad(undo->state == TRX_UNDO_TO_FREE); 01884 01885 /* Delete first the undo log segment in the file */ 01886 01887 mutex_exit(&(rseg->mutex)); 01888 01889 trx_undo_seg_free(undo); 01890 01891 mutex_enter(&(rseg->mutex)); 01892 01893 ut_ad(rseg->curr_size > undo->size); 01894 01895 rseg->curr_size -= undo->size; 01896 01897 trx_undo_mem_free(undo); 01898 } 01899 01900 mutex_exit(&(rseg->mutex)); 01901 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static ulint trx_undo_insert_header_reuse | ( | page_t * | undo_page, | |
| dulint | trx_id, | |||
| mtr_t * | mtr | |||
| ) | [static] |
Definition at line 687 of file trx0undo.c.
References FALSE, free, mach_read_from_2(), mach_write_to_1(), mach_write_to_2(), mach_write_to_8(), TRX_UNDO_ACTIVE, TRX_UNDO_DICT_TRANS, TRX_UNDO_INSERT, trx_undo_insert_header_reuse_log(), TRX_UNDO_LOG_OLD_HDR_SIZE, TRX_UNDO_LOG_START, TRX_UNDO_LOG_XA_HDR_SIZE, TRX_UNDO_PAGE_FREE, TRX_UNDO_PAGE_HDR, TRX_UNDO_PAGE_START, TRX_UNDO_PAGE_TYPE, TRX_UNDO_SEG_HDR, TRX_UNDO_SEG_HDR_SIZE, TRX_UNDO_STATE, TRX_UNDO_TRX_ID, TRX_UNDO_XID_EXISTS, UNIV_PAGE_SIZE, ut_a, and ut_ad.
Referenced by trx_undo_parse_page_header(), and trx_undo_reuse_cached().
00689 : undo log header byte offset on page */ 00690 page_t* undo_page, /* in: insert undo log segment header page, 00691 x-latched */ 00692 dulint trx_id, /* in: transaction id */ 00693 mtr_t* mtr) /* in: mtr */ 00694 { 00695 trx_upagef_t* page_hdr; 00696 trx_usegf_t* seg_hdr; 00697 trx_ulogf_t* log_hdr; 00698 ulint free; 00699 ulint new_free; 00700 00701 ut_ad(mtr && undo_page); 00702 00703 page_hdr = undo_page + TRX_UNDO_PAGE_HDR; 00704 seg_hdr = undo_page + TRX_UNDO_SEG_HDR; 00705 00706 free = TRX_UNDO_SEG_HDR + TRX_UNDO_SEG_HDR_SIZE; 00707 00708 ut_a(free + TRX_UNDO_LOG_XA_HDR_SIZE < UNIV_PAGE_SIZE - 100); 00709 00710 log_hdr = undo_page + free; 00711 00712 new_free = free + TRX_UNDO_LOG_OLD_HDR_SIZE; 00713 00714 /* Insert undo data is not needed after commit: we may free all 00715 the space on the page */ 00716 00717 ut_a(mach_read_from_2(undo_page + TRX_UNDO_PAGE_HDR 00718 + TRX_UNDO_PAGE_TYPE) 00719 == TRX_UNDO_INSERT); 00720 00721 mach_write_to_2(page_hdr + TRX_UNDO_PAGE_START, new_free); 00722 00723 mach_write_to_2(page_hdr + TRX_UNDO_PAGE_FREE, new_free); 00724 00725 mach_write_to_2(seg_hdr + TRX_UNDO_STATE, TRX_UNDO_ACTIVE); 00726 00727 log_hdr = undo_page + free; 00728 00729 mach_write_to_8(log_hdr + TRX_UNDO_TRX_ID, trx_id); 00730 mach_write_to_2(log_hdr + TRX_UNDO_LOG_START, new_free); 00731 00732 mach_write_to_1(log_hdr + TRX_UNDO_XID_EXISTS, FALSE); 00733 mach_write_to_1(log_hdr + TRX_UNDO_DICT_TRANS, FALSE); 00734 00735 /* Write the log record MLOG_UNDO_HDR_REUSE */ 00736 trx_undo_insert_header_reuse_log(undo_page, trx_id, mtr); 00737 00738 return(free); 00739 }
Here is the call graph for this function:

Here is the caller graph for this function:

| UNIV_INLINE void trx_undo_insert_header_reuse_log | ( | page_t * | undo_page, | |
| dulint | trx_id, | |||
| mtr_t * | mtr | |||
| ) |
Definition at line 636 of file trx0undo.c.
References mlog_catenate_dulint_compressed(), MLOG_UNDO_HDR_REUSE, and mlog_write_initial_log_record().
Referenced by trx_undo_insert_header_reuse().
00638 : undo log header page */ 00639 dulint trx_id, /* in: transaction id */ 00640 mtr_t* mtr) /* in: mtr */ 00641 { 00642 mlog_write_initial_log_record(undo_page, MLOG_UNDO_HDR_REUSE, mtr); 00643 00644 mlog_catenate_dulint_compressed(mtr, trx_id); 00645 }
Here is the call graph for this function:

Here is the caller graph for this function:

| ulint trx_undo_lists_init | ( | trx_rseg_t * | rseg | ) |
Definition at line 1320 of file trx0undo.c.
References FIL_NULL, mtr_commit(), mtr_start(), trx_rseg_struct::page_no, trx_undo_struct::size, trx_rseg_struct::space, SRV_FORCE_NO_UNDO_LOG_SCAN, srv_force_recovery, TRX_RSEG_N_SLOTS, trx_rsegf_get(), trx_rsegf_get_new(), trx_rsegf_get_nth_undo(), trx_undo_mem_create_at_db_start(), and UT_LIST_INIT.
Referenced by trx_rseg_mem_create().
01322 : the combined size of undo log segments 01323 in pages */ 01324 trx_rseg_t* rseg) /* in: rollback segment memory object */ 01325 { 01326 ulint page_no; 01327 trx_undo_t* undo; 01328 ulint size = 0; 01329 trx_rsegf_t* rseg_header; 01330 ulint i; 01331 mtr_t mtr; 01332 01333 UT_LIST_INIT(rseg->update_undo_list); 01334 UT_LIST_INIT(rseg->update_undo_cached); 01335 UT_LIST_INIT(rseg->insert_undo_list); 01336 UT_LIST_INIT(rseg->insert_undo_cached); 01337 01338 mtr_start(&mtr); 01339 01340 rseg_header = trx_rsegf_get_new(rseg->space, rseg->page_no, &mtr); 01341 01342 for (i = 0; i < TRX_RSEG_N_SLOTS; i++) { 01343 page_no = trx_rsegf_get_nth_undo(rseg_header, i, &mtr); 01344 01345 /* In forced recovery: try to avoid operations which look 01346 at database pages; undo logs are rapidly changing data, and 01347 the probability that they are in an inconsistent state is 01348 high */ 01349 01350 if (page_no != FIL_NULL 01351 && srv_force_recovery < SRV_FORCE_NO_UNDO_LOG_SCAN) { 01352 01353 undo = trx_undo_mem_create_at_db_start(rseg, i, 01354 page_no, &mtr); 01355 size += undo->size; 01356 01357 mtr_commit(&mtr); 01358 01359 mtr_start(&mtr); 01360 01361 rseg_header = trx_rsegf_get(rseg->space, 01362 rseg->page_no, &mtr); 01363 } 01364 } 01365 01366 mtr_commit(&mtr); 01367 01368 return(size); 01369 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static void trx_undo_mark_as_dict_operation | ( | trx_t * | trx, | |
| trx_undo_t * | undo, | |||
| mtr_t * | mtr | |||
| ) | [static] |
Definition at line 1628 of file trx0undo.c.
References trx_undo_struct::dict_operation, trx_struct::dict_operation, trx_undo_struct::hdr_offset, trx_undo_struct::hdr_page_no, MLOG_1BYTE, mlog_write_dulint(), mlog_write_ulint(), page_t, trx_undo_struct::space, trx_undo_struct::table_id, trx_struct::table_id, TRX_UNDO_DICT_TRANS, trx_undo_page_get(), TRX_UNDO_TABLE_ID, and ut_a.
Referenced by trx_undo_assign_undo().
01630 : dict op transaction */ 01631 trx_undo_t* undo, /* in: assigned undo log */ 01632 mtr_t* mtr) /* in: mtr */ 01633 { 01634 page_t* hdr_page; 01635 01636 ut_a(trx->dict_operation); 01637 01638 hdr_page = trx_undo_page_get(undo->space, undo->hdr_page_no, mtr); 01639 01640 mlog_write_ulint(hdr_page + undo->hdr_offset + 01641 TRX_UNDO_DICT_TRANS, 01642 trx->dict_operation, MLOG_1BYTE, mtr); 01643 01644 mlog_write_dulint(hdr_page + undo->hdr_offset + TRX_UNDO_TABLE_ID, 01645 trx->table_id, mtr); 01646 01647 undo->dict_operation = trx->dict_operation; 01648 undo->table_id = trx->table_id; 01649 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static trx_undo_t * trx_undo_mem_create | ( | trx_rseg_t * | rseg, | |
| ulint | id, | |||
| ulint | type, | |||
| dulint | trx_id, | |||
| XID * | xid, | |||
| ulint | page_no, | |||
| ulint | offset | |||
| ) | [static] |
Definition at line 1375 of file trx0undo.c.
References trx_undo_struct::del_marks, trx_undo_struct::dict_operation, trx_undo_struct::empty, FALSE, trx_undo_struct::guess_page, trx_undo_struct::hdr_offset, trx_undo_struct::hdr_page_no, trx_undo_struct::id, trx_undo_struct::last_page_no, mem_alloc, trx_rseg_struct::mutex, NULL, trx_undo_struct::rseg, trx_undo_struct::size, trx_rseg_struct::space, trx_undo_struct::space, trx_undo_struct::state, trx_undo_struct::top_page_no, TRUE, trx_undo_struct::trx_id, TRX_RSEG_N_SLOTS, TRX_UNDO_ACTIVE, trx_undo_struct::type, ut_ad, ut_error, and trx_undo_struct::xid.
Referenced by trx_undo_create(), and trx_undo_mem_create_at_db_start().
01377 : the undo log memory object */ 01378 trx_rseg_t* rseg, /* in: rollback segment memory object */ 01379 ulint id, /* in: slot index within rseg */ 01380 ulint type, /* in: type of the log: TRX_UNDO_INSERT or 01381 TRX_UNDO_UPDATE */ 01382 dulint trx_id, /* in: id of the trx for which the undo log 01383 is created */ 01384 XID* xid, /* in: X/Open transaction identification */ 01385 ulint page_no,/* in: undo log header page number */ 01386 ulint offset) /* in: undo log header byte offset on page */ 01387 { 01388 trx_undo_t* undo; 01389 01390 #ifdef UNIV_SYNC_DEBUG 01391 ut_ad(mutex_own(&(rseg->mutex))); 01392 #endif /* UNIV_SYNC_DEBUG */ 01393 01394 if (id >= TRX_RSEG_N_SLOTS) { 01395 fprintf(stderr, 01396 "InnoDB: Error: undo->id is %lu\n", (ulong) id); 01397 ut_error; 01398 } 01399 01400 undo = mem_alloc(sizeof(trx_undo_t)); 01401 01402 undo->id = id; 01403 undo->type = type; 01404 undo->state = TRX_UNDO_ACTIVE; 01405 undo->del_marks = FALSE; 01406 undo->trx_id = trx_id; 01407 undo->xid = *xid; 01408 01409 undo->dict_operation = FALSE; 01410 01411 undo->rseg = rseg; 01412 01413 undo->space = rseg->space; 01414 undo->hdr_page_no = page_no; 01415 undo->hdr_offset = offset; 01416 undo->last_page_no = page_no; 01417 undo->size = 1; 01418 01419 undo->empty = TRUE; 01420 undo->top_page_no = page_no; 01421 undo->guess_page = NULL; 01422 01423 return(undo); 01424 }
Here is the caller graph for this function:

| static trx_undo_t* trx_undo_mem_create_at_db_start | ( | trx_rseg_t * | rseg, | |
| ulint | id, | |||
| ulint | page_no, | |||
| mtr_t * | mtr | |||
| ) | [static] |
Definition at line 1197 of file trx0undo.c.
References add_to_list(), trx_undo_struct::dict_operation, trx_undo_struct::empty, FALSE, flst_get_last(), flst_get_len(), trx_undo_struct::last_page_no, mach_read_from_2(), memset, MLOG_1BYTE, MLOG_2BYTES, mtr_read_dulint(), mtr_read_ulint(), trx_rseg_struct::mutex, mutex_enter, mutex_exit(), NULL, offset, fil_addr_struct::page, page_t, trx_undo_struct::size, trx_rseg_struct::space, trx_undo_struct::state, trx_undo_struct::table_id, trx_undo_struct::top_offset, trx_undo_struct::top_page_no, trx_undo_struct::top_undo_no, TRUE, TRX_RSEG_N_SLOTS, TRX_UNDO_CACHED, TRX_UNDO_DICT_TRANS, TRX_UNDO_INSERT, TRX_UNDO_LAST_LOG, trx_undo_mem_create(), trx_undo_page_get(), trx_undo_page_get_last_rec(), TRX_UNDO_PAGE_HDR, TRX_UNDO_PAGE_LIST, TRX_UNDO_PAGE_TYPE, trx_undo_read_xid(), trx_undo_rec_get_undo_no(), TRX_UNDO_SEG_HDR, TRX_UNDO_STATE, TRX_UNDO_TABLE_ID, TRX_UNDO_TO_FREE, TRX_UNDO_TRX_ID, TRX_UNDO_UPDATE, TRX_UNDO_XID_EXISTS, ut_ad, ut_error, and UT_LIST_ADD_LAST.
Referenced by trx_undo_lists_init().
01199 : the undo log memory object */ 01200 trx_rseg_t* rseg, /* in: rollback segment memory object */ 01201 ulint id, /* in: slot index within rseg */ 01202 ulint page_no,/* in: undo log segment page number */ 01203 mtr_t* mtr) /* in: mtr */ 01204 { 01205 page_t* undo_page; 01206 trx_upagef_t* page_header; 01207 trx_usegf_t* seg_header; 01208 trx_ulogf_t* undo_header; 01209 trx_undo_t* undo; 01210 ulint type; 01211 ulint state; 01212 dulint trx_id; 01213 ulint offset; 01214 fil_addr_t last_addr; 01215 page_t* last_page; 01216 trx_undo_rec_t* rec; 01217 XID xid; 01218 ibool xid_exists = FALSE; 01219 01220 if (id >= TRX_RSEG_N_SLOTS) { 01221 fprintf(stderr, 01222 "InnoDB: Error: undo->id is %lu\n", (ulong) id); 01223 ut_error; 01224 } 01225 01226 undo_page = trx_undo_page_get(rseg->space, page_no, mtr); 01227 01228 page_header = undo_page + TRX_UNDO_PAGE_HDR; 01229 01230 type = mtr_read_ulint(page_header + TRX_UNDO_PAGE_TYPE, MLOG_2BYTES, 01231 mtr); 01232 seg_header = undo_page + TRX_UNDO_SEG_HDR; 01233 01234 state = mach_read_from_2(seg_header + TRX_UNDO_STATE); 01235 01236 offset = mach_read_from_2(seg_header + TRX_UNDO_LAST_LOG); 01237 01238 undo_header = undo_page + offset; 01239 01240 trx_id = mtr_read_dulint(undo_header + TRX_UNDO_TRX_ID, mtr); 01241 01242 xid_exists = mtr_read_ulint(undo_header + TRX_UNDO_XID_EXISTS, 01243 MLOG_1BYTE, mtr); 01244 01245 /* Read X/Open XA transaction identification if it exists, or 01246 set it to NULL. */ 01247 01248 memset(&xid, 0, sizeof(xid)); 01249 xid.formatID = -1; 01250 01251 if (xid_exists == TRUE) { 01252 trx_undo_read_xid(undo_header, &xid); 01253 } 01254 01255 mutex_enter(&(rseg->mutex)); 01256 01257 undo = trx_undo_mem_create(rseg, id, type, trx_id, &xid, 01258 page_no, offset); 01259 mutex_exit(&(rseg->mutex)); 01260 01261 undo->dict_operation = mtr_read_ulint( 01262 undo_header + TRX_UNDO_DICT_TRANS, 01263 MLOG_1BYTE, mtr); 01264 01265 undo->table_id = mtr_read_dulint(undo_header + TRX_UNDO_TABLE_ID, mtr); 01266 undo->state = state; 01267 undo->size = flst_get_len(seg_header + TRX_UNDO_PAGE_LIST, mtr); 01268 01269 /* If the log segment is being freed, the page list is inconsistent! */ 01270 if (state == TRX_UNDO_TO_FREE) { 01271 01272 goto add_to_list; 01273 } 01274 01275 last_addr = flst_get_last(seg_header + TRX_UNDO_PAGE_LIST, mtr); 01276 01277 undo->last_page_no = last_addr.page; 01278 undo->top_page_no = last_addr.page; 01279 01280 last_page = trx_undo_page_get(rseg->space, undo->last_page_no, mtr); 01281 01282 rec = trx_undo_page_get_last_rec(last_page, page_no, offset); 01283 01284 if (rec == NULL) { 01285 undo->empty = TRUE; 01286 } else { 01287 undo->empty = FALSE; 01288 undo->top_offset = rec - last_page; 01289 undo->top_undo_no = trx_undo_rec_get_undo_no(rec); 01290 } 01291 add_to_list: 01292 if (type == TRX_UNDO_INSERT) { 01293 if (state != TRX_UNDO_CACHED) { 01294 UT_LIST_ADD_LAST(undo_list, rseg->insert_undo_list, 01295 undo); 01296 } else { 01297 UT_LIST_ADD_LAST(undo_list, rseg->insert_undo_cached, 01298 undo); 01299 } 01300 } else { 01301 ut_ad(type == TRX_UNDO_UPDATE); 01302 if (state != TRX_UNDO_CACHED) { 01303 UT_LIST_ADD_LAST(undo_list, rseg->update_undo_list, 01304 undo); 01305 } else { 01306 UT_LIST_ADD_LAST(undo_list, rseg->update_undo_cached, 01307 undo); 01308 } 01309 } 01310 01311 return(undo); 01312 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static void trx_undo_mem_free | ( | trx_undo_t * | undo | ) | [static] |
Definition at line 1465 of file trx0undo.c.
References trx_undo_struct::id, mem_free, TRX_RSEG_N_SLOTS, and ut_error.
Referenced by trx_undo_insert_cleanup(), and trx_undo_update_cleanup().
01467 : the undo object to be freed */ 01468 { 01469 if (undo->id >= TRX_RSEG_N_SLOTS) { 01470 fprintf(stderr, 01471 "InnoDB: Error: undo->id is %lu\n", (ulong) undo->id); 01472 ut_error; 01473 } 01474 01475 mem_free(undo); 01476 }
Here is the caller graph for this function:

| static void trx_undo_mem_init_for_reuse | ( | trx_undo_t * | undo, | |
| dulint | trx_id, | |||
| XID * | xid, | |||
| ulint | offset | |||
| ) | [static] |
Definition at line 1430 of file trx0undo.c.
References trx_undo_struct::del_marks, trx_undo_struct::dict_operation, trx_undo_struct::empty, FALSE, trx_undo_struct::hdr_offset, trx_undo_struct::id, mem_analyze_corruption(), trx_undo_struct::rseg, trx_undo_struct::state, TRUE, trx_undo_struct::trx_id, TRX_RSEG_N_SLOTS, TRX_UNDO_ACTIVE, ut_ad, ut_error, and trx_undo_struct::xid.
Referenced by trx_undo_reuse_cached().
01432 : undo log to init */ 01433 dulint trx_id, /* in: id of the trx for which the undo log 01434 is created */ 01435 XID* xid, /* in: X/Open XA transaction identification*/ 01436 ulint offset) /* in: undo log header byte offset on page */ 01437 { 01438 #ifdef UNIV_SYNC_DEBUG 01439 ut_ad(mutex_own(&((undo->rseg)->mutex))); 01440 #endif /* UNIV_SYNC_DEBUG */ 01441 01442 if (undo->id >= TRX_RSEG_N_SLOTS) { 01443 fprintf(stderr, "InnoDB: Error: undo->id is %lu\n", 01444 (ulong) undo->id); 01445 01446 mem_analyze_corruption(undo); 01447 ut_error; 01448 } 01449 01450 undo->state = TRX_UNDO_ACTIVE; 01451 undo->del_marks = FALSE; 01452 undo->trx_id = trx_id; 01453 undo->xid = *xid; 01454 01455 undo->dict_operation = FALSE; 01456 01457 undo->hdr_offset = offset; 01458 undo->empty = TRUE; 01459 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 352 of file trx0undo.c.
References fil_page_set_type(), FIL_PAGE_UNDO_LOG, mach_write_to_2(), TRX_UNDO_PAGE_FREE, TRX_UNDO_PAGE_HDR, TRX_UNDO_PAGE_HDR_SIZE, trx_undo_page_init_log(), TRX_UNDO_PAGE_START, and TRX_UNDO_PAGE_TYPE.
Referenced by trx_undo_add_page(), trx_undo_parse_page_init(), and trx_undo_seg_create().
00354 : undo log segment page */ 00355 ulint type, /* in: undo log segment type */ 00356 mtr_t* mtr) /* in: mtr */ 00357 { 00358 trx_upagef_t* page_hdr; 00359 00360 page_hdr = undo_page + TRX_UNDO_PAGE_HDR; 00361 00362 mach_write_to_2(page_hdr + TRX_UNDO_PAGE_TYPE, type); 00363 00364 mach_write_to_2(page_hdr + TRX_UNDO_PAGE_START, 00365 TRX_UNDO_PAGE_HDR + TRX_UNDO_PAGE_HDR_SIZE); 00366 mach_write_to_2(page_hdr + TRX_UNDO_PAGE_FREE, 00367 TRX_UNDO_PAGE_HDR + TRX_UNDO_PAGE_HDR_SIZE); 00368 00369 fil_page_set_type(undo_page, FIL_PAGE_UNDO_LOG); 00370 00371 trx_undo_page_init_log(undo_page, type, mtr); 00372 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 309 of file trx0undo.c.
References mlog_catenate_ulint_compressed(), MLOG_UNDO_INIT, and mlog_write_initial_log_record().
Referenced by trx_undo_page_init().
00311 : undo log page */ 00312 ulint type, /* in: undo log type */ 00313 mtr_t* mtr) /* in: mtr */ 00314 { 00315 mlog_write_initial_log_record(undo_page, MLOG_UNDO_INIT, mtr); 00316 00317 mlog_catenate_ulint_compressed(mtr, type); 00318 }
Here is the call graph for this function:

Here is the caller graph for this function:

| byte* trx_undo_parse_discard_latest | ( | byte * | ptr, | |
| byte *end_ptr | __attribute__((unused)), | |||
| page_t * | page, | |||
| mtr_t * | mtr | |||
| ) |
Definition at line 757 of file trx0undo.c.
References trx_undo_discard_latest_update_undo(), and ut_ad.
00759 : end of log record or NULL */ 00760 byte* ptr, /* in: buffer */ 00761 byte* end_ptr __attribute__((unused)), /* in: buffer end */ 00762 page_t* page, /* in: page or NULL */ 00763 mtr_t* mtr) /* in: mtr or NULL */ 00764 { 00765 ut_ad(end_ptr); 00766 00767 if (page) { 00768 trx_undo_discard_latest_update_undo(page, mtr); 00769 } 00770 00771 return(ptr); 00772 }
Here is the call graph for this function:

| byte* trx_undo_parse_page_header | ( | ulint | type, | |
| byte * | ptr, | |||
| byte * | end_ptr, | |||
| page_t * | page, | |||
| mtr_t * | mtr | |||
| ) |
Definition at line 651 of file trx0undo.c.
References mach_dulint_parse_compressed(), MLOG_UNDO_HDR_CREATE, MLOG_UNDO_HDR_REUSE, NULL, trx_undo_header_create(), trx_undo_insert_header_reuse(), and ut_ad.
Referenced by recv_parse_or_apply_log_rec_body().
00653 : end of log record or NULL */ 00654 ulint type, /* in: MLOG_UNDO_HDR_CREATE or MLOG_UNDO_HDR_REUSE */ 00655 byte* ptr, /* in: buffer */ 00656 byte* end_ptr,/* in: buffer end */ 00657 page_t* page, /* in: page or NULL */ 00658 mtr_t* mtr) /* in: mtr or NULL */ 00659 { 00660 dulint trx_id; 00661 00662 ptr = mach_dulint_parse_compressed(ptr, end_ptr, &trx_id); 00663 00664 if (ptr == NULL) { 00665 00666 return(NULL); 00667 } 00668 00669 if (page) { 00670 if (type == MLOG_UNDO_HDR_CREATE) { 00671 trx_undo_header_create(page, trx_id, mtr); 00672 } else { 00673 ut_ad(type == MLOG_UNDO_HDR_REUSE); 00674 trx_undo_insert_header_reuse(page, trx_id, mtr); 00675 } 00676 } 00677 00678 return(ptr); 00679 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 324 of file trx0undo.c.
References mach_parse_compressed(), NULL, and trx_undo_page_init().
Referenced by recv_parse_or_apply_log_rec_body().
00326 : end of log record or NULL */ 00327 byte* ptr, /* in: buffer */ 00328 byte* end_ptr,/* in: buffer end */ 00329 page_t* page, /* in: page or NULL */ 00330 mtr_t* mtr) /* in: mtr or NULL */ 00331 { 00332 ulint type; 00333 00334 ptr = mach_parse_compressed(ptr, end_ptr, &type); 00335 00336 if (ptr == NULL) { 00337 00338 return(NULL); 00339 } 00340 00341 if (page) { 00342 trx_undo_page_init(page, type, mtr); 00343 } 00344 00345 return(ptr); 00346 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static void trx_undo_read_xid | ( | trx_ulogf_t * | log_hdr, | |
| XID * | xid | |||
| ) | [static] |
Definition at line 579 of file trx0undo.c.
References xid_t::bqual_length, xid_t::data, xid_t::formatID, xid_t::gtrid_length, mach_read_from_4(), memcpy, TRX_UNDO_XA_BQUAL_LEN, TRX_UNDO_XA_FORMAT, TRX_UNDO_XA_TRID_LEN, TRX_UNDO_XA_XID, and XIDDATASIZE.
Referenced by trx_undo_mem_create_at_db_start().
00581 : undo log header */ 00582 XID* xid) /* out: X/Open XA Transaction Identification */ 00583 { 00584 xid->formatID = (long)mach_read_from_4(log_hdr + TRX_UNDO_XA_FORMAT); 00585 00586 xid->gtrid_length = 00587 (long)mach_read_from_4(log_hdr + TRX_UNDO_XA_TRID_LEN); 00588 xid->bqual_length = 00589 (long)mach_read_from_4(log_hdr + TRX_UNDO_XA_BQUAL_LEN); 00590 00591 memcpy(xid->data, log_hdr + TRX_UNDO_XA_XID, XIDDATASIZE); 00592 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static trx_undo_t* trx_undo_reuse_cached | ( | trx_t * | trx, | |
| trx_rseg_t * | rseg, | |||
| ulint | type, | |||
| dulint | trx_id, | |||
| XID * | xid, | |||
| mtr_t * | mtr | |||
| ) | [static] |
Definition at line 1545 of file trx0undo.c.
References trx_undo_struct::hdr_page_no, trx_undo_struct::id, mach_read_from_2(), mem_analyze_corruption(), trx_rseg_struct::mutex, NULL, offset, page_t, trx_undo_struct::size, trx_undo_struct::space, trx_struct::support_xa, TRX_RSEG_N_SLOTS, trx_undo_header_add_space_for_xid(), trx_undo_header_create(), TRX_UNDO_INSERT, trx_undo_insert_header_reuse(), trx_undo_mem_init_for_reuse(), trx_undo_page_get(), TRX_UNDO_PAGE_HDR, TRX_UNDO_PAGE_TYPE, TRX_UNDO_UPDATE, ut_a, ut_ad, ut_error, UT_LIST_GET_FIRST, and UT_LIST_REMOVE.
Referenced by trx_undo_assign_undo().
01547 : the undo log memory object, NULL if 01548 none cached */ 01549 trx_t* trx, /* in: transaction */ 01550 trx_rseg_t* rseg, /* in: rollback segment memory object */ 01551 ulint type, /* in: type of the log: TRX_UNDO_INSERT or 01552 TRX_UNDO_UPDATE */ 01553 dulint trx_id, /* in: id of the trx for which the undo log 01554 is used */ 01555 XID* xid, /* in: X/Open XA transaction identification */ 01556 mtr_t* mtr) /* in: mtr */ 01557 { 01558 trx_undo_t* undo; 01559 page_t* undo_page; 01560 ulint offset; 01561 01562 #ifdef UNIV_SYNC_DEBUG 01563 ut_ad(mutex_own(&(rseg->mutex))); 01564 #endif /* UNIV_SYNC_DEBUG */ 01565 01566 if (type == TRX_UNDO_INSERT) { 01567 01568 undo = UT_LIST_GET_FIRST(rseg->insert_undo_cached); 01569 if (undo == NULL) { 01570 01571 return(NULL); 01572 } 01573 01574 UT_LIST_REMOVE(undo_list, rseg->insert_undo_cached, undo); 01575 } else { 01576 ut_ad(type == TRX_UNDO_UPDATE); 01577 01578 undo = UT_LIST_GET_FIRST(rseg->update_undo_cached); 01579 if (undo == NULL) { 01580 01581 return(NULL); 01582 } 01583 01584 UT_LIST_REMOVE(undo_list, rseg->update_undo_cached, undo); 01585 } 01586 01587 ut_ad(undo->size == 1); 01588 01589 if (undo->id >= TRX_RSEG_N_SLOTS) { 01590 fprintf(stderr, "InnoDB: Error: undo->id is %lu\n", 01591 (ulong) undo->id); 01592 mem_analyze_corruption(undo); 01593 ut_error; 01594 } 01595 01596 undo_page = trx_undo_page_get(undo->space, undo->hdr_page_no, mtr); 01597 01598 if (type == TRX_UNDO_INSERT) { 01599 offset = trx_undo_insert_header_reuse(undo_page, trx_id, mtr); 01600 01601 if (trx->support_xa) { 01602 trx_undo_header_add_space_for_xid(undo_page, 01603 undo_page + offset, mtr); 01604 } 01605 } else { 01606 ut_a(mach_read_from_2(undo_page + TRX_UNDO_PAGE_HDR 01607 + TRX_UNDO_PAGE_TYPE) 01608 == TRX_UNDO_UPDATE); 01609 01610 offset = trx_undo_header_create(undo_page, trx_id, mtr); 01611 01612 if (trx->support_xa) { 01613 trx_undo_header_add_space_for_xid(undo_page, 01614 undo_page + offset, mtr); 01615 } 01616 } 01617 01618 trx_undo_mem_init_for_reuse(undo, trx_id, xid, offset); 01619 01620 return(undo); 01621 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static page_t* trx_undo_seg_create | ( | trx_rseg_t *rseg | __attribute__((unused)), | |
| trx_rsegf_t * | rseg_hdr, | |||
| ulint | type, | |||
| ulint * | id, | |||
| mtr_t * | mtr | |||
| ) | [static] |
Definition at line 378 of file trx0undo.c.
References buf_frame_get_page_no(), buf_frame_get_space_id(), fil_space_release_free_extents(), flst_add_last(), flst_init(), fseg_create_general(), fsp_reserve_free_extents(), FSP_UNDO, MLOG_2BYTES, mlog_write_ulint(), NULL, page_t, SYNC_TRX_UNDO_PAGE, TRUE, trx_rsegf_set_nth_undo(), trx_rsegf_undo_find_free(), TRX_UNDO_FSEG_HEADER, TRX_UNDO_LAST_LOG, TRX_UNDO_PAGE_FREE, TRX_UNDO_PAGE_HDR, trx_undo_page_init(), TRX_UNDO_PAGE_LIST, TRX_UNDO_PAGE_NODE, TRX_UNDO_SEG_HDR, TRX_UNDO_SEG_HDR_SIZE, ut_ad, and ut_print_timestamp().
Referenced by trx_undo_create().
00380 : segment header page x-latched, NULL 00381 if no space left */ 00382 trx_rseg_t* rseg __attribute__((unused)),/* in: rollback segment */ 00383 trx_rsegf_t* rseg_hdr,/* in: rollback segment header, page 00384 x-latched */ 00385 ulint type, /* in: type of the segment: TRX_UNDO_INSERT or 00386 TRX_UNDO_UPDATE */ 00387 ulint* id, /* out: slot index within rseg header */ 00388 mtr_t* mtr) /* in: mtr */ 00389 { 00390 ulint slot_no; 00391 ulint space; 00392 page_t* undo_page; 00393 trx_upagef_t* page_hdr; 00394 trx_usegf_t* seg_hdr; 00395 ulint n_reserved; 00396 ibool success; 00397 00398 ut_ad(mtr && id && rseg_hdr); 00399 #ifdef UNIV_SYNC_DEBUG 00400 ut_ad(mutex_own(&(rseg->mutex))); 00401 #endif /* UNIV_SYNC_DEBUG */ 00402 00403 /* fputs(type == TRX_UNDO_INSERT 00404 ? "Creating insert undo log segment\n" 00405 : "Creating update undo log segment\n", stderr); */ 00406 slot_no = trx_rsegf_undo_find_free(rseg_hdr, mtr); 00407 00408 if (slot_no == ULINT_UNDEFINED) { 00409 ut_print_timestamp(stderr); 00410 fprintf(stderr, 00411 "InnoDB: Warning: cannot find a free slot for an undo log. Do you have too\n" 00412 "InnoDB: many active transactions running concurrently?\n"); 00413 00414 return(NULL); 00415 } 00416 00417 space = buf_frame_get_space_id(rseg_hdr); 00418 00419 success = fsp_reserve_free_extents(&n_reserved, space, 2, FSP_UNDO, 00420 mtr); 00421 if (!success) { 00422 00423 return(NULL); 00424 } 00425 00426 /* Allocate a new file segment for the undo log */ 00427 undo_page = fseg_create_general(space, 0, 00428 TRX_UNDO_SEG_HDR + TRX_UNDO_FSEG_HEADER, TRUE, mtr); 00429 00430 fil_space_release_free_extents(space, n_reserved); 00431 00432 if (undo_page == NULL) { 00433 /* No space left */ 00434 00435 return(NULL); 00436 } 00437 00438 #ifdef UNIV_SYNC_DEBUG 00439 buf_page_dbg_add_level(undo_page, SYNC_TRX_UNDO_PAGE); 00440 #endif /* UNIV_SYNC_DEBUG */ 00441 00442 page_hdr = undo_page + TRX_UNDO_PAGE_HDR; 00443 seg_hdr = undo_page + TRX_UNDO_SEG_HDR; 00444 00445 trx_undo_page_init(undo_page, type, mtr); 00446 00447 mlog_write_ulint(page_hdr + TRX_UNDO_PAGE_FREE, 00448 TRX_UNDO_SEG_HDR + TRX_UNDO_SEG_HDR_SIZE, 00449 MLOG_2BYTES, mtr); 00450 00451 mlog_write_ulint(seg_hdr + TRX_UNDO_LAST_LOG, 0, MLOG_2BYTES, mtr); 00452 00453 flst_init(seg_hdr + TRX_UNDO_PAGE_LIST, mtr); 00454 00455 flst_add_last(seg_hdr + TRX_UNDO_PAGE_LIST, 00456 page_hdr + TRX_UNDO_PAGE_NODE, mtr); 00457 00458 trx_rsegf_set_nth_undo(rseg_hdr, slot_no, 00459 buf_frame_get_page_no(undo_page), mtr); 00460 *id = slot_no; 00461 00462 return(undo_page); 00463 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static void trx_undo_seg_free | ( | trx_undo_t * | undo | ) | [static] |
Definition at line 1147 of file trx0undo.c.
References FALSE, FIL_NULL, yaSSL::finished, fseg_free_step(), trx_undo_struct::hdr_page_no, trx_undo_struct::id, kernel_mutex, mtr_commit(), mtr_start(), trx_rseg_struct::mutex, mutex_enter, mutex_exit(), trx_rseg_struct::page_no, trx_undo_struct::rseg, trx_rseg_struct::space, trx_undo_struct::space, trx_rsegf_get(), trx_rsegf_set_nth_undo(), TRX_UNDO_FSEG_HEADER, trx_undo_page_get(), TRX_UNDO_SEG_HDR, and ut_ad.
Referenced by trx_undo_insert_cleanup().
01149 : undo log */ 01150 { 01151 trx_rseg_t* rseg; 01152 fseg_header_t* file_seg; 01153 trx_rsegf_t* rseg_header; 01154 trx_usegf_t* seg_header; 01155 ibool finished; 01156 mtr_t mtr; 01157 01158 finished = FALSE; 01159 rseg = undo->rseg; 01160 01161 while (!finished) { 01162 01163 mtr_start(&mtr); 01164 #ifdef UNIV_SYNC_DEBUG 01165 ut_ad(!mutex_own(&kernel_mutex)); 01166 #endif /* UNIV_SYNC_DEBUG */ 01167 mutex_enter(&(rseg->mutex)); 01168 01169 seg_header = trx_undo_page_get(undo->space, undo->hdr_page_no, 01170 &mtr) + TRX_UNDO_SEG_HDR; 01171 01172 file_seg = seg_header + TRX_UNDO_FSEG_HEADER; 01173 01174 finished = fseg_free_step(file_seg, &mtr); 01175 01176 if (finished) { 01177 /* Update the rseg header */ 01178 rseg_header = trx_rsegf_get(rseg->space, rseg->page_no, 01179 &mtr); 01180 trx_rsegf_set_nth_undo(rseg_header, undo->id, FIL_NULL, 01181 &mtr); 01182 } 01183 01184 mutex_exit(&(rseg->mutex)); 01185 mtr_commit(&mtr); 01186 } 01187 }
Here is the call graph for this function:

Here is the caller graph for this function:

| page_t* trx_undo_set_state_at_finish | ( | trx_t *trx | __attribute__((unused)), | |
| trx_undo_t * | undo, | |||
| mtr_t * | mtr | |||
| ) |
Definition at line 1722 of file trx0undo.c.
References trx_undo_struct::hdr_page_no, trx_undo_struct::id, mach_read_from_2(), mem_analyze_corruption(), MLOG_2BYTES, mlog_write_ulint(), page_t, trx_undo_struct::size, trx_undo_struct::space, trx_undo_struct::state, TRX_RSEG_N_SLOTS, TRX_UNDO_CACHED, TRX_UNDO_INSERT, TRX_UNDO_PAGE_FREE, trx_undo_page_get(), TRX_UNDO_PAGE_HDR, TRX_UNDO_PAGE_REUSE_LIMIT, TRX_UNDO_SEG_HDR, TRX_UNDO_STATE, TRX_UNDO_TO_FREE, TRX_UNDO_TO_PURGE, trx_undo_struct::type, ut_ad, and ut_error.
01724 : undo log segment header page, 01725 x-latched */ 01726 trx_t* trx __attribute__((unused)), /* in: transaction */ 01727 trx_undo_t* undo, /* in: undo log memory copy */ 01728 mtr_t* mtr) /* in: mtr */ 01729 { 01730 trx_usegf_t* seg_hdr; 01731 trx_upagef_t* page_hdr; 01732 page_t* undo_page; 01733 ulint state; 01734 01735 ut_ad(trx && undo && mtr); 01736 01737 if (undo->id >= TRX_RSEG_N_SLOTS) { 01738 fprintf(stderr, "InnoDB: Error: undo->id is %lu\n", 01739 (ulong) undo->id); 01740 mem_analyze_corruption(undo); 01741 ut_error; 01742 } 01743 01744 undo_page = trx_undo_page_get(undo->space, undo->hdr_page_no, mtr); 01745 01746 seg_hdr = undo_page + TRX_UNDO_SEG_HDR; 01747 page_hdr = undo_page + TRX_UNDO_PAGE_HDR; 01748 01749 if (undo->size == 1 && mach_read_from_2(page_hdr + TRX_UNDO_PAGE_FREE) 01750 < TRX_UNDO_PAGE_REUSE_LIMIT) { 01751 state = TRX_UNDO_CACHED; 01752 01753 } else if (undo->type == TRX_UNDO_INSERT) { 01754 01755 state = TRX_UNDO_TO_FREE; 01756 } else { 01757 state = TRX_UNDO_TO_PURGE; 01758 } 01759 01760 undo->state = state; 01761 01762 mlog_write_ulint(seg_hdr + TRX_UNDO_STATE, state, MLOG_2BYTES, mtr); 01763 01764 return(undo_page); 01765 }
Here is the call graph for this function:

| page_t* trx_undo_set_state_at_prepare | ( | trx_t * | trx, | |
| trx_undo_t * | undo, | |||
| mtr_t * | mtr | |||
| ) |
Definition at line 1771 of file trx0undo.c.
References trx_undo_struct::hdr_page_no, trx_undo_struct::id, mach_read_from_2(), mem_analyze_corruption(), MLOG_1BYTE, MLOG_2BYTES, mlog_write_ulint(), offset, page_t, trx_undo_struct::space, trx_undo_struct::state, TRUE, TRX_RSEG_N_SLOTS, TRX_UNDO_LAST_LOG, trx_undo_page_get(), TRX_UNDO_PAGE_HDR, TRX_UNDO_PREPARED, TRX_UNDO_SEG_HDR, TRX_UNDO_STATE, trx_undo_write_xid(), TRX_UNDO_XID_EXISTS, ut_ad, ut_error, trx_struct::xid, and trx_undo_struct::xid.
Referenced by trx_prepare_off_kernel().
01773 : undo log segment header page, 01774 x-latched */ 01775 trx_t* trx, /* in: transaction */ 01776 trx_undo_t* undo, /* in: undo log memory copy */ 01777 mtr_t* mtr) /* in: mtr */ 01778 { 01779 trx_usegf_t* seg_hdr; 01780 trx_upagef_t* page_hdr; 01781 trx_ulogf_t* undo_header; 01782 page_t* undo_page; 01783 ulint offset; 01784 01785 ut_ad(trx && undo && mtr); 01786 01787 if (undo->id >= TRX_RSEG_N_SLOTS) { 01788 fprintf(stderr, "InnoDB: Error: undo->id is %lu\n", 01789 (ulong) undo->id); 01790 mem_analyze_corruption(undo); 01791 ut_error; 01792 } 01793 01794 undo_page = trx_undo_page_get(undo->space, undo->hdr_page_no, mtr); 01795 01796 seg_hdr = undo_page + TRX_UNDO_SEG_HDR; 01797 page_hdr = undo_page + TRX_UNDO_PAGE_HDR; 01798 01799 /*------------------------------*/ 01800 undo->state = TRX_UNDO_PREPARED; 01801 undo->xid = trx->xid; 01802 /*------------------------------*/ 01803 01804 mlog_write_ulint(seg_hdr + TRX_UNDO_STATE, undo->state, 01805 MLOG_2BYTES, mtr); 01806 01807 offset = mach_read_from_2(seg_hdr + TRX_UNDO_LAST_LOG); 01808 undo_header = undo_page + offset; 01809 01810 mlog_write_ulint(undo_header + TRX_UNDO_XID_EXISTS, 01811 TRUE, MLOG_1BYTE, mtr); 01812 01813 trx_undo_write_xid(undo_header, &undo->xid, mtr); 01814 01815 return(undo_page); 01816 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void trx_undo_truncate_end | ( | trx_t * | trx, | |
| trx_undo_t * | undo, | |||
| dulint | limit | |||
| ) |
Definition at line 1002 of file trx0undo.c.
References trx_undo_struct::hdr_offset, trx_undo_struct::hdr_page_no, trx_undo_struct::last_page_no, mtr_commit(), mtr_start(), trx_rseg_struct::mutex, NULL, page_t, trx_struct::rseg, trx_undo_struct::space, trx_undo_free_page_in_rollback(), trx_undo_page_get(), trx_undo_page_get_last_rec(), trx_undo_page_get_prev_rec(), trx_undo_rec_get_undo_no(), trx_struct::undo_mutex, ut_ad, and ut_dulint_cmp().
Referenced by trx_roll_try_truncate().
01004 : transaction whose undo log it is */ 01005 trx_undo_t* undo, /* in: undo log */ 01006 dulint limit) /* in: all undo records with undo number 01007 >= this value should be truncated */ 01008 { 01009 page_t* undo_page; 01010 ulint last_page_no; 01011 trx_undo_rec_t* rec; 01012 trx_undo_rec_t* trunc_here; 01013 trx_rseg_t* rseg; 01014 mtr_t mtr; 01015 01016 #ifdef UNIV_SYNC_DEBUG 01017 ut_ad(mutex_own(&(trx->undo_mutex))); 01018 ut_ad(mutex_own(&(trx->rseg->mutex))); 01019 #endif /* UNIV_SYNC_DEBUG */ 01020 01021 rseg = trx->rseg; 01022 01023 for (;;) { 01024 mtr_start(&mtr); 01025 01026 trunc_here = NULL; 01027 01028 last_page_no = undo->last_page_no; 01029 01030 undo_page = trx_undo_page_get(undo->space, last_page_no, &mtr); 01031 01032 rec = trx_undo_page_get_last_rec(undo_page, undo->hdr_page_no, 01033 undo->hdr_offset); 01034 for (;;) { 01035 if (rec == NULL) { 01036 if (last_page_no == undo->hdr_page_no) { 01037 01038 goto function_exit; 01039 } 01040 01041 trx_undo_free_page_in_rollback(trx, undo, 01042 last_page_no, &mtr); 01043 break; 01044 } 01045 01046 if (ut_dulint_cmp(trx_undo_rec_get_undo_no(rec), limit) 01047 >= 0) { 01048 /* Truncate at least this record off, maybe 01049 more */ 01050 trunc_here = rec; 01051 } else { 01052 goto function_exit; 01053 } 01054 01055 rec = trx_undo_page_get_prev_rec(rec, 01056 undo->hdr_page_no, 01057 undo->hdr_offset); 01058 } 01059 01060 mtr_commit(&mtr); 01061 } 01062 01063 function_exit: 01064 if (trunc_here) { 01065 mlog_write_ulint(undo_page + TRX_UNDO_PAGE_HDR 01066 + TRX_UNDO_PAGE_FREE, 01067 trunc_here - undo_page, MLOG_2BYTES, &mtr); 01068 } 01069 01070 mtr_commit(&mtr); 01071 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void trx_undo_truncate_start | ( | trx_rseg_t * | rseg, | |
| ulint | space, | |||
| ulint | hdr_page_no, | |||
| ulint | hdr_offset, | |||
| dulint | limit | |||
| ) |
Definition at line 1078 of file trx0undo.c.
References buf_frame_align(), buf_frame_get_page_no(), mtr_commit(), mtr_start(), trx_rseg_struct::mutex, NULL, page_t, RW_X_LATCH, TRUE, trx_undo_empty_header_page(), trx_undo_free_page(), trx_undo_get_first_rec(), trx_undo_page_get_last_rec(), trx_undo_rec_get_undo_no(), ut_ad, ut_dulint_cmp(), and ut_dulint_zero.
Referenced by trx_purge_truncate_rseg_history().
01080 : rollback segment */ 01081 ulint space, /* in: space id of the log */ 01082 ulint hdr_page_no, /* in: header page number */ 01083 ulint hdr_offset, /* in: header offset on the page */ 01084 dulint limit) /* in: all undo pages with undo numbers < 01085 this value should be truncated; NOTE that 01086 the function only frees whole pages; the 01087 header page is not freed, but emptied, if 01088 all the records there are < limit */ 01089 { 01090 page_t* undo_page; 01091 trx_undo_rec_t* rec; 01092 trx_undo_rec_t* last_rec; 01093 ulint page_no; 01094 mtr_t mtr; 01095 01096 #ifdef UNIV_SYNC_DEBUG 01097 ut_ad(mutex_own(&(rseg->mutex))); 01098 #endif /* UNIV_SYNC_DEBUG */ 01099 01100 if (0 == ut_dulint_cmp(limit, ut_dulint_zero)) { 01101 01102 return; 01103 } 01104 loop: 01105 mtr_start(&mtr); 01106 01107 rec = trx_undo_get_first_rec(space, hdr_page_no, hdr_offset, 01108 RW_X_LATCH, &mtr); 01109 if (rec == NULL) { 01110 /* Already empty */ 01111 01112 mtr_commit(&mtr); 01113 01114 return; 01115 } 01116 01117 undo_page = buf_frame_align(rec); 01118 01119 last_rec = trx_undo_page_get_last_rec(undo_page, hdr_page_no, 01120 hdr_offset); 01121 if (ut_dulint_cmp(trx_undo_rec_get_undo_no(last_rec), limit) >= 0) { 01122 01123 mtr_commit(&mtr); 01124 01125 return; 01126 } 01127 01128 page_no = buf_frame_get_page_no(undo_page); 01129 01130 if (page_no == hdr_page_no) { 01131 trx_undo_empty_header_page(space, hdr_page_no, hdr_offset, 01132 &mtr); 01133 } else { 01134 trx_undo_free_page(rseg, TRUE, space, hdr_page_no, 01135 page_no, &mtr); 01136 } 01137 01138 mtr_commit(&mtr); 01139 01140 goto loop; 01141 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1824 of file trx0undo.c.
References trx_rseg_struct::mutex, NULL, trx_struct::rseg, trx_undo_struct::state, trx_purge_add_update_undo_to_history(), TRX_UNDO_CACHED, trx_undo_mem_free(), TRX_UNDO_TO_PURGE, trx_struct::update_undo, ut_ad, UT_LIST_ADD_FIRST, and UT_LIST_REMOVE.
Referenced by trx_commit_off_kernel().
01826 : trx owning the update undo log */ 01827 page_t* undo_page, /* in: update undo log header page, 01828 x-latched */ 01829 mtr_t* mtr) /* in: mtr */ 01830 { 01831 trx_rseg_t* rseg; 01832 trx_undo_t* undo; 01833 01834 undo = trx->update_undo; 01835 rseg = trx->rseg; 01836 01837 #ifdef UNIV_SYNC_DEBUG 01838 ut_ad(mutex_own(&(rseg->mutex))); 01839 #endif /* UNIV_SYNC_DEBUG */ 01840 trx_purge_add_update_undo_to_history(trx, undo_page, mtr); 01841 01842 UT_LIST_REMOVE(undo_list, rseg->update_undo_list, undo); 01843 01844 trx->update_undo = NULL; 01845 01846 if (undo->state == TRX_UNDO_CACHED) { 01847 01848 UT_LIST_ADD_FIRST(undo_list, rseg->update_undo_cached, undo); 01849 } else { 01850 ut_ad(undo->state == TRX_UNDO_TO_PURGE); 01851 01852 trx_undo_mem_free(undo); 01853 } 01854 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static void trx_undo_write_xid | ( | trx_ulogf_t * | log_hdr, | |
| const XID * | xid, | |||
| mtr_t * | mtr | |||
| ) | [static] |
Definition at line 556 of file trx0undo.c.
References xid_t::bqual_length, xid_t::data, xid_t::formatID, xid_t::gtrid_length, MLOG_4BYTES, mlog_write_string(), mlog_write_ulint(), TRX_UNDO_XA_BQUAL_LEN, TRX_UNDO_XA_FORMAT, TRX_UNDO_XA_TRID_LEN, TRX_UNDO_XA_XID, and XIDDATASIZE.
Referenced by trx_undo_set_state_at_prepare().
00558 : undo log header */ 00559 const XID* xid, /* in: X/Open XA Transaction Identification */ 00560 mtr_t* mtr) /* in: mtr */ 00561 { 00562 mlog_write_ulint(log_hdr + TRX_UNDO_XA_FORMAT, 00563 (ulint)xid->formatID, MLOG_4BYTES, mtr); 00564 00565 mlog_write_ulint(log_hdr + TRX_UNDO_XA_TRID_LEN, 00566 (ulint)xid->gtrid_length, MLOG_4BYTES, mtr); 00567 00568 mlog_write_ulint(log_hdr + TRX_UNDO_XA_BQUAL_LEN, 00569 (ulint)xid->bqual_length, MLOG_4BYTES, mtr); 00570 00571 mlog_write_string(log_hdr + TRX_UNDO_XA_XID, (const byte*) xid->data, 00572 XIDDATASIZE, mtr); 00573 }
Here is the call graph for this function:

Here is the caller graph for this function:

1.4.7

