32 #ifndef UNIV_HOTBACKUP
82 static const char* file_format_name_map[] = {
112 static const ulint FILE_FORMAT_NAME_N
113 =
sizeof(file_format_name_map) /
sizeof(file_format_name_map[0]);
115 #ifdef UNIV_PFS_MUTEX
117 UNIV_INTERN mysql_pfs_key_t file_format_max_mutex_key;
118 UNIV_INTERN mysql_pfs_key_t trx_sys_mutex_key;
121 #ifndef UNIV_HOTBACKUP
124 UNIV_INTERN uint trx_rseg_n_slots_debug = 0;
143 trx_list_t* trx_list;
153 ut_ad(trx_assert_started(in_trx));
156 trx != NULL && trx != in_trx;
201 const char* file_name,
233 (byte*) file_name, 1 +
ut_strlen(file_name),
239 || (offset >> 32) > 0) {
243 (ulint)(offset >> 32),
249 (ulint)(offset & 0xFFFFFFFFUL),
263 ulint trx_sys_mysql_bin_log_pos_high;
264 ulint trx_sys_mysql_bin_log_pos_low;
287 = (((ib_int64_t) trx_sys_mysql_bin_log_pos_high) << 32)
288 + (ib_int64_t) trx_sys_mysql_bin_log_pos_low;
295 "InnoDB: Last MySQL binlog file position %lu %lu,"
297 trx_sys_mysql_bin_log_pos_high, trx_sys_mysql_bin_log_pos_low,
328 "InnoDB: In a MySQL replication slave the last"
329 " master binlog file\n"
330 "InnoDB: position %lu %lu, file name %s\n",
371 for (i = 0; i < TRX_SYS_N_RSEGS; i++) {
382 return(ULINT_UNDEFINED);
413 buf_block_dbg_add_level(block, SYNC_TRX_SYS_HEADER);
417 page = buf_block_get_frame(block);
438 len =
ut_max(TRX_SYS_OLD_N_RSEGS, TRX_SYS_N_RSEGS)
439 * TRX_SYS_RSEG_SLOT_SIZE;
440 memset(ptr, 0xff, len);
448 + page - sys_header, mtr);
455 ut_a(slot_no == TRX_SYS_SYSTEM_RSEG_ID);
456 ut_a(page_no == FSP_FIRST_RSEG_PAGE_NO);
463 trx_rseg_compare_last_trx_no(
477 }
else if (cmp > 0) {
496 ib_uint64_t rows_to_undo = 0;
497 const char* unit =
"";
504 trx_rseg_compare_last_trx_no,
558 if (rows_to_undo > 1000000000) {
560 rows_to_undo = rows_to_undo / 1000000;
564 "InnoDB: %lu transaction(s) which must be"
565 " rolled back or cleaned up\n"
566 "InnoDB: in total %lu%s row operations to undo\n",
568 (ulong) rows_to_undo, unit);
570 fprintf(stderr,
"InnoDB: Trx id counter is " TRX_ID_FMT "\n",
594 mutex_create(trx_sys_mutex_key, &
trx_sys->
mutex, SYNC_TRX_SYS);
608 trx_sysf_create(&mtr);
618 trx_sys_file_format_max_write(
627 ib_uint64_t tag_value;
632 TRX_SYS_SPACE, 0, TRX_SYS_PAGE_NO, RW_X_LATCH, &mtr);
634 file_format_max.
id = format_id;
641 *name = file_format_max.
name;
656 trx_sys_file_format_max_read(
void)
662 ib_id_t file_format_id;
669 TRX_SYS_SPACE, 0, TRX_SYS_PAGE_NO, RW_X_LATCH, &mtr);
678 if (file_format_id >= FILE_FORMAT_NAME_N) {
681 return(ULINT_UNDEFINED);
684 return((ulint) file_format_id);
696 ut_a(
id < FILE_FORMAT_NAME_N);
698 return(file_format_name_map[
id]);
716 format_id = trx_sys_file_format_max_read();
717 if (format_id == ULINT_UNDEFINED) {
720 format_id = UNIV_FORMAT_MIN;
724 "Highest supported file format is %s.",
727 if (format_id > UNIV_FORMAT_MAX) {
729 ut_a(format_id < FILE_FORMAT_NAME_N);
731 ib_logf(max_format_id <= UNIV_FORMAT_MAX
732 ? IB_LOG_LEVEL_ERROR : IB_LOG_LEVEL_WARN,
733 "The system tablespace is in a file "
734 "format that this version doesn't support - %s.",
737 if (max_format_id <= UNIV_FORMAT_MAX) {
742 format_id = (format_id > max_format_id) ? format_id : max_format_id;
746 file_format_max.
id = format_id;
766 ut_a(format_id <= UNIV_FORMAT_MAX);
768 mutex_enter(&file_format_max.
mutex);
771 if (format_id != file_format_max.
id) {
773 ret = trx_sys_file_format_max_write(format_id, name);
776 mutex_exit(&file_format_max.
mutex);
793 format_id = trx_sys_file_format_max_read();
796 if (format_id == ULINT_UNDEFINED) {
816 ut_a(format_id <= UNIV_FORMAT_MAX);
818 mutex_enter(&file_format_max.
mutex);
820 if (format_id > file_format_max.
id) {
822 ret = trx_sys_file_format_max_write(format_id, name);
825 mutex_exit(&file_format_max.
mutex);
838 return(file_format_max.
name);
848 mutex_create(file_format_max_mutex_key,
849 &file_format_max.
mutex, SYNC_FILE_FORMAT_TAG);
853 file_format_max.
id = UNIV_FORMAT_MIN;
882 ut_a(n_spaces < TRX_SYS_N_RSEGS);
883 ut_a(n_rsegs <= TRX_SYS_N_RSEGS);
886 return(ULINT_UNDEFINED);
897 if (n_used == ULINT_UNDEFINED) {
898 n_used = TRX_SYS_N_RSEGS;
906 ulint new_rsegs = n_rsegs - n_used;
908 for (i = 0; i < new_rsegs; ++
i) {
915 space = (i % n_spaces) + 1;
929 "%lu rollback segment(s) are active.", n_used);
940 trx_sys_print_mysql_binlog_offset_from_page(
948 sys_header = page + TRX_SYS;
955 "ibbackup: Last MySQL binlog file position %lu %lu,"
976 trx_sys_read_file_format_id(
978 const char *pathname,
985 byte
buf[UNIV_PAGE_SIZE * 2];
988 ib_id_t file_format_id;
990 *format_id = ULINT_UNDEFINED;
992 file = os_file_create_simple_no_error_handling(
993 innodb_file_data_key,
1006 " ibbackup: Error: trying to read system tablespace "
1008 " ibbackup: but could not open the tablespace "
1009 "file %s!\n", pathname);
1015 success = os_file_read_no_error_handling(
1016 file, page, TRX_SYS_PAGE_NO * UNIV_PAGE_SIZE, UNIV_PAGE_SIZE);
1025 " ibbackup: Error: trying to read system tablespace "
1027 " ibbackup: but failed to read the tablespace "
1028 "file %s!\n", pathname);
1030 os_file_close(file);
1033 os_file_close(file);
1040 if (file_format_id >= FILE_FORMAT_NAME_N) {
1046 *format_id = (ulint) file_format_id;
1056 trx_sys_read_pertable_file_format_id(
1058 const char *pathname,
1065 byte buf[UNIV_PAGE_SIZE * 2];
1070 *format_id = ULINT_UNDEFINED;
1072 file = os_file_create_simple_no_error_handling(
1073 innodb_file_data_key,
1086 " ibbackup: Error: trying to read per-table "
1087 "tablespace format,\n"
1088 " ibbackup: but could not open the tablespace "
1089 "file %s!\n", pathname);
1096 success = os_file_read_no_error_handling(file, page, 0, UNIV_PAGE_SIZE);
1105 " ibbackup: Error: trying to per-table data file "
1107 " ibbackup: but failed to read the tablespace "
1108 "file %s!\n", pathname);
1110 os_file_close(file);
1113 os_file_close(file);
1122 }
else if (flags & 1) {
1124 *format_id = (flags / 32) % 128;
1142 if (!(
id < FILE_FORMAT_NAME_N)) {
1147 return(file_format_name_map[
id]);
1152 #ifndef UNIV_HOTBACKUP
1174 "InnoDB: Error: all read views were not closed"
1175 " before shutdown:\n"
1176 "InnoDB: %lu read views open \n",
1202 for (i = 0; i < TRX_SYS_N_RSEGS; ++
i) {
1216 while (view != NULL) {
1245 trx_sys_any_active_transactions(
void)
1248 ulint total_trx = 0;
1269 trx_sys_validate_trx_list_low(
1271 trx_list_t* trx_list)
1275 const trx_t* prev_trx = NULL;
1289 ut_a(prev_trx == NULL || prev_trx->
id > trx->id);
1300 trx_sys_validate_trx_list(
void)