diff options
author | unknown <heikki@hundin.mysql.fi> | 2002-06-22 20:41:14 +0300 |
---|---|---|
committer | unknown <heikki@hundin.mysql.fi> | 2002-06-22 20:41:14 +0300 |
commit | 1081513a12851d432103eaabcb6533c84062196c (patch) | |
tree | cd94be28879d52101bd7438dc97dc04856d81739 /innobase/trx/trx0sys.c | |
parent | b7b988b3c36fa7a1f0a284d6478bbccbe706c09f (diff) | |
download | mariadb-git-1081513a12851d432103eaabcb6533c84062196c.tar.gz |
Many files:
Merge 3.23.52
innobase/btr/btr0btr.c:
Merge 3.23.52
innobase/btr/btr0cur.c:
Merge 3.23.52
innobase/btr/btr0sea.c:
Merge 3.23.52
innobase/include/btr0btr.h:
Merge 3.23.52
innobase/include/btr0cur.h:
Merge 3.23.52
innobase/include/btr0sea.h:
Merge 3.23.52
innobase/include/buf0buf.h:
Merge 3.23.52
innobase/include/buf0rea.h:
Merge 3.23.52
innobase/include/data0data.h:
Merge 3.23.52
innobase/include/data0data.ic:
Merge 3.23.52
innobase/include/log0log.h:
Merge 3.23.52
innobase/include/log0log.ic:
Merge 3.23.52
innobase/include/os0file.h:
Merge 3.23.52
innobase/include/page0page.h:
Merge 3.23.52
innobase/include/page0page.ic:
Merge 3.23.52
innobase/include/row0mysql.h:
Merge 3.23.52
innobase/include/trx0roll.h:
Merge 3.23.52
innobase/include/trx0sys.h:
Merge 3.23.52
innobase/include/trx0trx.h:
Merge 3.23.52
innobase/include/ut0ut.h:
Merge 3.23.52
innobase/include/univ.i:
Merge 3.23.52
innobase/include/ut0ut.ic:
Merge 3.23.52
innobase/buf/buf0buf.c:
Merge 3.23.52
innobase/buf/buf0rea.c:
Merge 3.23.52
innobase/data/data0data.c:
Merge 3.23.52
innobase/dict/dict0crea.c:
Merge 3.23.52
innobase/dict/dict0dict.c:
Merge 3.23.52
innobase/dict/dict0load.c:
Merge 3.23.52
innobase/dict/dict0mem.c:
Merge 3.23.52
innobase/fsp/fsp0fsp.c:
Merge 3.23.52
innobase/ibuf/ibuf0ibuf.c:
Merge 3.23.52
innobase/lock/lock0lock.c:
Merge 3.23.52
innobase/log/log0log.c:
Merge 3.23.52
innobase/log/log0recv.c:
Merge 3.23.52
innobase/mtr/mtr0log.c:
Merge 3.23.52
innobase/mtr/mtr0mtr.c:
Merge 3.23.52
innobase/os/os0file.c:
Merge 3.23.52
innobase/page/page0cur.c:
Merge 3.23.52
innobase/page/page0page.c:
Merge 3.23.52
innobase/rem/rem0cmp.c:
Merge 3.23.52
innobase/row/row0ins.c:
Merge 3.23.52
innobase/row/row0mysql.c:
Merge 3.23.52
innobase/row/row0purge.c:
Merge 3.23.52
innobase/row/row0upd.c:
Merge 3.23.52
innobase/srv/srv0srv.c:
Merge 3.23.52
innobase/srv/srv0start.c:
Merge 3.23.52
innobase/trx/trx0roll.c:
Merge 3.23.52
innobase/trx/trx0sys.c:
Merge 3.23.52
innobase/trx/trx0trx.c:
Merge 3.23.52
innobase/trx/trx0undo.c:
Merge 3.23.52
innobase/ut/ut0mem.c:
Merge 3.23.52
innobase/ut/ut0ut.c:
Merge 3.23.52
Diffstat (limited to 'innobase/trx/trx0sys.c')
-rw-r--r-- | innobase/trx/trx0sys.c | 121 |
1 files changed, 84 insertions, 37 deletions
diff --git a/innobase/trx/trx0sys.c b/innobase/trx/trx0sys.c index 32a1db48488..675cdf1b7e4 100644 --- a/innobase/trx/trx0sys.c +++ b/innobase/trx/trx0sys.c @@ -26,6 +26,14 @@ Created 3/26/1996 Heikki Tuuri trx_sys_t* trx_sys = NULL; trx_doublewrite_t* trx_doublewrite = NULL; +/* In a MySQL replication slave, in crash recovery we store the master log +file name and position here. We have successfully got the updates to InnoDB +up to this position. If .._pos is -1, it means no crash recovery was needed, +or there was no master log position info inside InnoDB. */ + +char trx_sys_mysql_master_log_name[TRX_SYS_MYSQL_LOG_NAME_LEN]; +ib_longlong trx_sys_mysql_master_log_pos = -1; + /******************************************************************** Determines if a page number is located inside the doublewrite buffer. */ @@ -427,75 +435,62 @@ trx_sys_flush_max_trx_id(void) /********************************************************************* Updates the offset information about the end of the MySQL binlog entry -which corresponds to the transaction just being committed. */ +which corresponds to the transaction just being committed. In a MySQL +replication slave updates the latest master binlog position up to which +replication has proceeded. */ void trx_sys_update_mysql_binlog_offset( /*===============================*/ - trx_t* trx, /* in: transaction being committed */ - mtr_t* mtr) /* in: mtr */ + char* file_name,/* in: MySQL log file name */ + ib_longlong offset, /* in: position in that log file */ + ulint field, /* in: offset of the MySQL log info field in + the trx sys header */ + mtr_t* mtr) /* in: mtr */ { trx_sysf_t* sys_header; - char namebuf[TRX_SYS_MYSQL_LOG_NAME_LEN]; - - ut_ad(trx->mysql_log_file_name); - memset(namebuf, ' ', TRX_SYS_MYSQL_LOG_NAME_LEN - 1); - namebuf[TRX_SYS_MYSQL_LOG_NAME_LEN - 1] = '\0'; + if (ut_strlen(file_name) >= TRX_SYS_MYSQL_LOG_NAME_LEN) { - /* Copy the whole MySQL log file name to the buffer, or only the - last characters, if it does not fit */ + /* We cannot fit the name to the 512 bytes we have reserved */ - if (ut_strlen(trx->mysql_log_file_name) - > TRX_SYS_MYSQL_LOG_NAME_LEN - 1) { - ut_memcpy(namebuf, trx->mysql_log_file_name - + ut_strlen(trx->mysql_log_file_name) - - (TRX_SYS_MYSQL_LOG_NAME_LEN - 1), - TRX_SYS_MYSQL_LOG_NAME_LEN - 1); - } else { - ut_memcpy(namebuf, trx->mysql_log_file_name, - 1 + ut_strlen(trx->mysql_log_file_name)); + return; } - namebuf[TRX_SYS_MYSQL_LOG_NAME_LEN - 1] = '\0'; - sys_header = trx_sysf_get(mtr); - if (mach_read_from_4(sys_header + TRX_SYS_MYSQL_LOG_INFO + if (mach_read_from_4(sys_header + field + TRX_SYS_MYSQL_LOG_MAGIC_N_FLD) != TRX_SYS_MYSQL_LOG_MAGIC_N) { - mlog_write_ulint(sys_header + TRX_SYS_MYSQL_LOG_INFO + mlog_write_ulint(sys_header + field + TRX_SYS_MYSQL_LOG_MAGIC_N_FLD, TRX_SYS_MYSQL_LOG_MAGIC_N, MLOG_4BYTES, mtr); } - if (0 != ut_memcmp(sys_header + TRX_SYS_MYSQL_LOG_INFO - + TRX_SYS_MYSQL_LOG_NAME, - namebuf, TRX_SYS_MYSQL_LOG_NAME_LEN)) { + if (0 != ut_memcmp(sys_header + field + TRX_SYS_MYSQL_LOG_NAME, + file_name, 1 + ut_strlen(file_name))) { - mlog_write_string(sys_header + TRX_SYS_MYSQL_LOG_INFO + mlog_write_string(sys_header + field + TRX_SYS_MYSQL_LOG_NAME, - namebuf, TRX_SYS_MYSQL_LOG_NAME_LEN, mtr); + file_name, 1 + ut_strlen(file_name), mtr); } - if (mach_read_from_4(sys_header + TRX_SYS_MYSQL_LOG_INFO + if (mach_read_from_4(sys_header + field + TRX_SYS_MYSQL_LOG_OFFSET_HIGH) > 0 - || (trx->mysql_log_offset >> 32) > 0) { + || (offset >> 32) > 0) { - mlog_write_ulint(sys_header + TRX_SYS_MYSQL_LOG_INFO + mlog_write_ulint(sys_header + field + TRX_SYS_MYSQL_LOG_OFFSET_HIGH, - (ulint)(trx->mysql_log_offset >> 32), + (ulint)(offset >> 32), MLOG_4BYTES, mtr); } - mlog_write_ulint(sys_header + TRX_SYS_MYSQL_LOG_INFO + mlog_write_ulint(sys_header + field + TRX_SYS_MYSQL_LOG_OFFSET_LOW, - (ulint)(trx->mysql_log_offset & 0xFFFFFFFF), + (ulint)(offset & 0xFFFFFFFF), MLOG_4BYTES, mtr); - - trx->mysql_log_file_name = NULL; } /********************************************************************* @@ -533,6 +528,58 @@ trx_sys_print_mysql_binlog_offset(void) mtr_commit(&mtr); } +/********************************************************************* +Prints to stderr the MySQL master log offset info in the trx system header if +the magic number shows it valid. */ + +void +trx_sys_print_mysql_master_log_pos(void) +/*====================================*/ +{ + trx_sysf_t* sys_header; + mtr_t mtr; + + mtr_start(&mtr); + + sys_header = trx_sysf_get(&mtr); + + if (mach_read_from_4(sys_header + TRX_SYS_MYSQL_MASTER_LOG_INFO + + TRX_SYS_MYSQL_LOG_MAGIC_N_FLD) + != TRX_SYS_MYSQL_LOG_MAGIC_N) { + + mtr_commit(&mtr); + + return; + } + + fprintf(stderr, +"InnoDB: In a MySQL replication slave the last master binlog file\n" +"InnoDB: position %lu %lu, file name %s\n", + mach_read_from_4(sys_header + TRX_SYS_MYSQL_MASTER_LOG_INFO + + TRX_SYS_MYSQL_LOG_OFFSET_HIGH), + mach_read_from_4(sys_header + TRX_SYS_MYSQL_MASTER_LOG_INFO + + TRX_SYS_MYSQL_LOG_OFFSET_LOW), + sys_header + TRX_SYS_MYSQL_MASTER_LOG_INFO + + TRX_SYS_MYSQL_LOG_NAME); + /* Copy the master log position info to global variables we can + use in ha_innobase.cc to initialize glob_mi to right values */ + + ut_memcpy(trx_sys_mysql_master_log_name, + sys_header + TRX_SYS_MYSQL_MASTER_LOG_INFO + + TRX_SYS_MYSQL_LOG_NAME, + TRX_SYS_MYSQL_LOG_NAME_LEN); + + trx_sys_mysql_master_log_pos = + (((ib_longlong)mach_read_from_4( + sys_header + TRX_SYS_MYSQL_MASTER_LOG_INFO + + TRX_SYS_MYSQL_LOG_OFFSET_HIGH)) + << 32) + + (ib_longlong) + mach_read_from_4(sys_header + TRX_SYS_MYSQL_MASTER_LOG_INFO + + TRX_SYS_MYSQL_LOG_OFFSET_LOW); + mtr_commit(&mtr); +} + /******************************************************************** Looks for a free slot for a rollback segment in the trx system file copy. */ @@ -660,7 +707,7 @@ trx_sys_init_at_db_start(void) if (UT_LIST_GET_LEN(trx_sys->trx_list) > 0) { fprintf(stderr, - "InnoDB: %lu uncommitted transaction(s) which must be rolled back\n", + "InnoDB: %lu transaction(s) which must be rolled back or cleaned up\n", UT_LIST_GET_LEN(trx_sys->trx_list)); fprintf(stderr, "InnoDB: Trx id counter is %lu %lu\n", |