57
57
UNIV_INTERN ibool recv_replay_file_ops = TRUE;
58
58
#endif /* !UNIV_HOTBACKUP */
60
#include <drizzled/errmsg_print.h>
62
60
/** Log records are stored in the hash table in chunks at most of this size;
63
61
this must be less than UNIV_PAGE_SIZE as it is stored in the buffer pool */
64
62
#define RECV_DATA_BLOCK_SIZE (MEM_MAX_ALLOC_IN_BUF - sizeof(recv_data_t))
360
358
ut_ad(mutex_own(&(recv_sys->mutex)));
362
360
if (recv_sys->n_addrs != 0) {
363
drizzled::errmsg_printf(drizzled::error::ERROR,
364
"InnoDB: Error: %lu pages with log records were left unprocessed!\n"
365
"InnoDB: Maximum page number with log records on it %lu\n",
366
(ulong) recv_sys->n_addrs,
367
(ulong) recv_max_parsed_page_no);
362
"InnoDB: Error: %lu pages with log records"
363
" were left unprocessed!\n"
364
"InnoDB: Maximum page number with"
365
" log records on it %lu\n",
366
(ulong) recv_sys->n_addrs,
367
(ulong) recv_max_parsed_page_no);
371
371
hash_table_free(recv_sys->addr_hash);
686
686
if (!recv_check_cp_is_consistent(buf)) {
687
687
#ifdef UNIV_DEBUG
688
688
if (log_debug_writes) {
689
drizzled::errmsg_printf(drizzled::error::INFO,
690
"InnoDB: Checkpoint in group %lu at %lu invalid, %lu\n",
693
(ulong) mach_read_from_4(
695
+ LOG_CHECKPOINT_CHECKSUM_1));
690
"InnoDB: Checkpoint in group"
691
" %lu at %lu invalid, %lu\n",
694
(ulong) mach_read_from_4(
696
+ LOG_CHECKPOINT_CHECKSUM_1));
698
699
#endif /* UNIV_DEBUG */
733
735
if (*max_group == NULL) {
735
drizzled::errmsg_printf(drizzled::error::ERROR,
736
"InnoDB: No valid checkpoint found. If this error appears when you are"
737
" creating an InnoDB database,InnoDB: the problem may be that during"
738
" an earlier attempt you managed to create the InnoDB data files,"
739
" but log file creation failed. If that is the case, please refer to\n"
740
"InnoDB: " REFMAN "error-creating-innodb.html\n");
738
"InnoDB: No valid checkpoint found.\n"
739
"InnoDB: If this error appears when you are"
740
" creating an InnoDB database,\n"
741
"InnoDB: the problem may be that during"
742
" an earlier attempt you managed\n"
743
"InnoDB: to create the InnoDB data files,"
744
" but log file creation failed.\n"
745
"InnoDB: If that is the case, please refer to\n"
746
"InnoDB: " REFMAN "error-creating-innodb.html\n");
744
750
return(DB_SUCCESS);
2741
2747
if (finished || (recv_scan_print_counter % 80 == 0)) {
2743
drizzled::errmsg_printf(drizzled::error::INFO,
2744
"InnoDB: Doing recovery: scanned up to log sequence number %"PRIu64" ",
2745
*group_scanned_lsn);
2750
"InnoDB: Doing recovery: scanned up to"
2751
" log sequence number %"PRIu64"\n",
2752
*group_scanned_lsn);
2816
2823
#ifdef UNIV_DEBUG
2817
2824
if (log_debug_writes) {
2818
drizzled::errmsg_printf(drizzled::error::INFO,
2819
"InnoDB: Scanned group %lu up to log sequence number %"PRIu64" ", (ulong) group->id, *group_scanned_lsn);
2826
"InnoDB: Scanned group %lu up to"
2827
" log sequence number %"PRIu64"\n",
2829
*group_scanned_lsn);
2821
2831
#endif /* UNIV_DEBUG */
2920
2930
if (srv_force_recovery >= SRV_FORCE_NO_LOG_REDO) {
2921
drizzled::errmsg_printf(drizzled::error::INFO,
2922
"InnoDB: The user has set SRV_FORCE_NO_LOG_REDO on Skipping log redo.");
2932
"InnoDB: The user has set SRV_FORCE_NO_LOG_REDO on\n");
2934
"InnoDB: Skipping log redo\n");
2924
2936
return(DB_SUCCESS);
2963
2975
/* This log file was created by ibbackup --restore: print
2964
2976
a note to the user about it */
2966
drizzled::errmsg_printf(drizzled::error::INFO,
2967
"InnoDB: The log file was created by ibbackup --apply-log at %s\n",
2968
log_hdr_buf + LOG_FILE_WAS_CREATED_BY_HOT_BACKUP);
2969
drizzled::errmsg_printf(drizzled::error::INFO,
2970
"InnoDB: NOTE: the following crash recovery is part of a normal restore.\n");
2972
/* Wipe over the label now */
2974
memset(log_hdr_buf + LOG_FILE_WAS_CREATED_BY_HOT_BACKUP,
2976
/* Write to the log file to wipe over the label */
2977
fil_io(OS_FILE_WRITE | OS_FILE_LOG, TRUE,
2978
max_cp_group->space_id, 0,
2979
0, 0, OS_FILE_LOG_BLOCK_SIZE,
2980
log_hdr_buf, max_cp_group);
2979
"InnoDB: The log file was created by"
2980
" ibbackup --apply-log at\n"
2982
log_hdr_buf + LOG_FILE_WAS_CREATED_BY_HOT_BACKUP);
2984
"InnoDB: NOTE: the following crash recovery"
2985
" is part of a normal restore.\n");
2987
/* Wipe over the label now */
2989
memset(log_hdr_buf + LOG_FILE_WAS_CREATED_BY_HOT_BACKUP,
2991
/* Write to the log file to wipe over the label */
2992
fil_io(OS_FILE_WRITE | OS_FILE_LOG, TRUE,
2993
max_cp_group->space_id, 0,
2994
0, 0, OS_FILE_LOG_BLOCK_SIZE,
2995
log_hdr_buf, max_cp_group);
2983
2998
#ifdef UNIV_LOG_ARCHIVE
3094
3109
|| checkpoint_lsn != min_flushed_lsn) {
3096
3111
if (checkpoint_lsn < max_flushed_lsn) {
3097
drizzled::errmsg_printf(drizzled::error::ERROR,
3098
"InnoDB: #########################"
3099
"#################################\n"
3102
"InnoDB: The log sequence number"
3103
" in ibdata files is higher\n"
3104
"InnoDB: than the log sequence number"
3105
" in the ib_logfiles! Are you sure\n"
3106
"InnoDB: you are using the right"
3107
" ib_logfiles to start up"
3109
"InnoDB: Log sequence number in"
3110
" ib_logfiles is %"PRIu64", log\n"
3111
"InnoDB: sequence numbers stamped"
3112
" to ibdata file headers are between\n"
3113
"InnoDB: %"PRIu64" and %"PRIu64".\n"
3114
"InnoDB: #########################"
3115
"#################################\n",
3113
"InnoDB: #########################"
3114
"#################################\n"
3117
"InnoDB: The log sequence number"
3118
" in ibdata files is higher\n"
3119
"InnoDB: than the log sequence number"
3120
" in the ib_logfiles! Are you sure\n"
3121
"InnoDB: you are using the right"
3122
" ib_logfiles to start up"
3124
"InnoDB: Log sequence number in"
3125
" ib_logfiles is %"PRIu64", log\n"
3126
"InnoDB: sequence numbers stamped"
3127
" to ibdata file headers are between\n"
3128
"InnoDB: %"PRIu64" and %"PRIu64".\n"
3129
"InnoDB: #########################"
3130
"#################################\n",
3121
if (not recv_needed_recovery) {
3122
drizzled::errmsg_printf(drizzled::error::ERROR,
3123
"InnoDB: The log sequence number in ibdata files does not match the log sequence number in the ib_logfiles!");
3124
recv_init_crash_recovery();
3136
if (!recv_needed_recovery) {
3138
"InnoDB: The log sequence number"
3139
" in ibdata files does not match\n"
3140
"InnoDB: the log sequence number"
3141
" in the ib_logfiles!\n");
3142
recv_init_crash_recovery();
3134
3152
/* We currently have only one log group */
3135
3153
if (group_scanned_lsn < checkpoint_lsn) {
3136
drizzled::errmsg_printf(drizzled::error::ERROR,
3137
"InnoDB: ERROR: We were only able to scan the log up to %"PRIu64", but a checkpoint was at %"PRIu64". "
3138
"It is possible that the database is now corrupt!",
3154
ut_print_timestamp(stderr);
3156
" InnoDB: ERROR: We were only able to scan the log"
3158
"InnoDB: %"PRIu64", but a checkpoint was at %"PRIu64".\n"
3159
"InnoDB: It is possible that"
3160
" the database is now corrupt!\n",
3143
3165
if (group_scanned_lsn < recv_max_page_lsn) {
3144
drizzled::errmsg_printf(drizzled::error::ERROR,
3145
"InnoDB: ERROR: We were only able to scan the log up to %"PRIu64" "
3146
" but a database page a had an lsn %"PRIu64". It is possible that the database is now corrupt!",
3166
ut_print_timestamp(stderr);
3168
" InnoDB: ERROR: We were only able to scan the log"
3169
" up to %"PRIu64"\n"
3170
"InnoDB: but a database page a had an lsn %"PRIu64"."
3171
" It is possible that the\n"
3172
"InnoDB: database is now corrupt!\n",
3151
3177
if (recv_sys->recovered_lsn < checkpoint_lsn) {
3237
3263
#ifdef UNIV_DEBUG
3238
3264
if (log_debug_writes) {
3239
drizzled::errmsg_printf(drizzled::error::INFO,
3240
"InnoDB: Log records applied to the database.");
3266
"InnoDB: Log records applied to the database\n");
3242
3268
#endif /* UNIV_DEBUG */
3270
if (recv_needed_recovery) {
3271
trx_sys_print_mysql_master_log_pos();
3272
trx_sys_print_mysql_binlog_offset();
3244
3275
if (recv_sys->found_corrupt_log) {
3245
drizzled::errmsg_printf(drizzled::error::ERROR,
3246
"InnoDB: WARNING: the log file may have been corrupt and it\n"
3247
"InnoDB: is possible that the log scan or parsing did not proceed\n"
3248
"InnoDB: far enough in recovery. Please run CHECK TABLE on your InnoDB tables to check that they are ok! "
3249
"InnoDB: It may be safest to recover your database from a backup!");
3278
"InnoDB: WARNING: the log file may have been"
3280
"InnoDB: is possible that the log scan or parsing"
3281
" did not proceed\n"
3282
"InnoDB: far enough in recovery. Please run"
3284
"InnoDB: on your InnoDB tables to check that"
3286
"InnoDB: It may be safest to recover your"
3287
" InnoDB database from\n"
3288
"InnoDB: a backup!\n");
3252
3291
/* Free the resources of the recovery system */
3404
3443
name, OS_FILE_CREATE,
3405
3444
OS_FILE_READ_WRITE,
3408
drizzled::errmsg_printf(drizzled::error::ERROR,
3409
"InnoDB: Cannot create %s. Check that the file does not exist yet.\n", name);
3448
"InnoDB: Cannot create %s. Check that"
3449
" the file does not exist yet.\n", name);
3414
drizzled::errmsg_printf(drizzled::error::INFO,
3415
"Setting log file size to %lu %lu\n",
3416
(ulong) ut_get_high32(log_file_size),
3417
(ulong) log_file_size & 0xFFFFFFFFUL);
3455
"Setting log file size to %lu %lu\n",
3456
(ulong) ut_get_high32(log_file_size),
3457
(ulong) log_file_size & 0xFFFFFFFFUL);
3419
3459
success = os_file_set_size(name, log_file,
3420
3460
log_file_size & 0xFFFFFFFFUL,
3421
3461
ut_get_high32(log_file_size));
3424
drizzled::errmsg_printf(drizzled::error::ERROR,
3425
"InnoDB: Cannot set %s size to %lu %lu\n",
3426
name, (ulong) ut_get_high32(log_file_size),
3427
(ulong) (log_file_size & 0xFFFFFFFFUL));
3465
"InnoDB: Cannot set %s size to %lu %lu\n",
3466
name, (ulong) ut_get_high32(log_file_size),
3467
(ulong) (log_file_size & 0xFFFFFFFFUL));
3431
3471
os_file_flush(log_file);
3445
3485
name, OS_FILE_OPEN,
3446
3486
OS_FILE_READ_WRITE, &success);
3447
3487
if (!success) {
3448
drizzled::errmsg_printf(drizzled::error::ERROR, "InnoDB: Cannot open %s.\n", name);
3488
fprintf(stderr, "InnoDB: Cannot open %s.\n", name);
3453
3493
os_file_write(name, log_file, buf, 0, 0,
3454
3494
LOG_FILE_HDR_SIZE + OS_FILE_LOG_BLOCK_SIZE);
3528
3568
ut_a(file_size_high == 0);
3530
drizzled::errmsg_printf(drizzled::error::INFO,
3531
"InnoDB: Opened archived log file %s\n", name);
3570
fprintf(stderr, "InnoDB: Opened archived log file %s\n", name);
3533
3572
ret = os_file_close(file_handle);
3535
3574
if (file_size < LOG_FILE_HDR_SIZE) {
3536
drizzled::errmsg_printf(drizzled::error::ERROR,
3537
"InnoDB: Archive file header incomplete %s\n", name);
3576
"InnoDB: Archive file header incomplete %s\n", name);
3558
3597
if (mach_read_from_4(buf + LOG_GROUP_ID) != group->id
3559
3598
|| mach_read_from_4(buf + LOG_FILE_NO)
3560
3599
!= group->archived_file_no) {
3561
drizzled::errmsg_printf(drizzled::error::ERROR,
3562
3601
"InnoDB: Archive file header inconsistent %s\n", name);
3567
3606
if (!mach_read_from_4(buf + LOG_FILE_ARCH_COMPLETED)) {
3568
drizzled::errmsg_printf(drizzled::error::ERROR,
3569
3608
"InnoDB: Archive file not completely written %s\n",
3578
3617
if (!recv_sys->scanned_lsn) {
3580
3619
if (recv_sys->parse_start_lsn < start_lsn) {
3581
drizzled::errmsg_printf(drizzled::error::ERROR,
3582
"InnoDB: Archive log file %s starts from too big a lsn\n", name);
3621
"InnoDB: Archive log file %s"
3622
" starts from too big a lsn\n",
3586
3627
recv_sys->scanned_lsn = start_lsn;
3589
3630
if (recv_sys->scanned_lsn != start_lsn) {
3591
drizzled::errmsg_printf(drizzled::error::ERROR,
3592
"InnoDB: Archive log file %s starts from a wrong lsn\n", name);
3633
"InnoDB: Archive log file %s starts from"
3596
3639
read_offset = LOG_FILE_HDR_SIZE;
3611
3654
#ifdef UNIV_DEBUG
3612
3655
if (log_debug_writes) {
3613
drizzled::errmsg_printf(drizzled::error::INFO,
3614
"InnoDB: Archive read starting at lsn %"PRIu64", len %lu from file %s\n",
3615
start_lsn, (ulong) len, name);
3657
"InnoDB: Archive read starting at"
3658
" lsn %"PRIu64", len %lu from file %s\n",
3617
3662
#endif /* UNIV_DEBUG */