57
57
UNIV_INTERN ibool recv_replay_file_ops = TRUE;
58
58
#endif /* !UNIV_HOTBACKUP */
60
#include <drizzled/errmsg_print.h>
60
62
/** Log records are stored in the hash table in chunks at most of this size;
61
63
this must be less than UNIV_PAGE_SIZE as it is stored in the buffer pool */
62
64
#define RECV_DATA_BLOCK_SIZE (MEM_MAX_ALLOC_IN_BUF - sizeof(recv_data_t))
358
360
ut_ad(mutex_own(&(recv_sys->mutex)));
360
362
if (recv_sys->n_addrs != 0) {
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);
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);
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) {
690
"InnoDB: Checkpoint in group"
691
" %lu at %lu invalid, %lu\n",
694
(ulong) mach_read_from_4(
696
+ LOG_CHECKPOINT_CHECKSUM_1));
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));
699
698
#endif /* UNIV_DEBUG */
735
733
if (*max_group == NULL) {
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");
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");
750
744
return(DB_SUCCESS);
2747
2741
if (finished || (recv_scan_print_counter % 80 == 0)) {
2750
"InnoDB: Doing recovery: scanned up to"
2751
" log sequence number %"PRIu64"\n",
2752
*group_scanned_lsn);
2743
drizzled::errmsg_printf(drizzled::error::INFO,
2744
"InnoDB: Doing recovery: scanned up to log sequence number %"PRIu64" ",
2745
*group_scanned_lsn);
2823
2816
#ifdef UNIV_DEBUG
2824
2817
if (log_debug_writes) {
2826
"InnoDB: Scanned group %lu up to"
2827
" log sequence number %"PRIu64"\n",
2829
*group_scanned_lsn);
2818
drizzled::errmsg_printf(drizzled::error::INFO,
2819
"InnoDB: Scanned group %lu up to log sequence number %"PRIu64" ", (ulong) group->id, *group_scanned_lsn);
2831
2821
#endif /* UNIV_DEBUG */
2930
2920
if (srv_force_recovery >= SRV_FORCE_NO_LOG_REDO) {
2932
"InnoDB: The user has set SRV_FORCE_NO_LOG_REDO on\n");
2934
"InnoDB: Skipping log redo\n");
2921
drizzled::errmsg_printf(drizzled::error::INFO,
2922
"InnoDB: The user has set SRV_FORCE_NO_LOG_REDO on Skipping log redo.");
2936
2924
return(DB_SUCCESS);
2975
2963
/* This log file was created by ibbackup --restore: print
2976
2964
a note to the user about it */
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);
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);
2998
2983
#ifdef UNIV_LOG_ARCHIVE
3109
3094
|| checkpoint_lsn != min_flushed_lsn) {
3111
3096
if (checkpoint_lsn < max_flushed_lsn) {
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",
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",
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();
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();
3152
3134
/* We currently have only one log group */
3153
3135
if (group_scanned_lsn < checkpoint_lsn) {
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",
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!",
3165
3143
if (group_scanned_lsn < recv_max_page_lsn) {
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",
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!",
3177
3151
if (recv_sys->recovered_lsn < checkpoint_lsn) {
3263
3237
#ifdef UNIV_DEBUG
3264
3238
if (log_debug_writes) {
3266
"InnoDB: Log records applied to the database\n");
3239
drizzled::errmsg_printf(drizzled::error::INFO,
3240
"InnoDB: Log records applied to the database.");
3268
3242
#endif /* UNIV_DEBUG */
3270
3244
if (recv_sys->found_corrupt_log) {
3273
"InnoDB: WARNING: the log file may have been"
3275
"InnoDB: is possible that the log scan or parsing"
3276
" did not proceed\n"
3277
"InnoDB: far enough in recovery. Please run"
3279
"InnoDB: on your InnoDB tables to check that"
3281
"InnoDB: It may be safest to recover your"
3282
" InnoDB database from\n"
3283
"InnoDB: a backup!\n");
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!");
3286
3252
/* Free the resources of the recovery system */
3438
3404
name, OS_FILE_CREATE,
3439
3405
OS_FILE_READ_WRITE,
3443
"InnoDB: Cannot create %s. Check that"
3444
" the file does not exist yet.\n", name);
3408
drizzled::errmsg_printf(drizzled::error::ERROR,
3409
"InnoDB: Cannot create %s. Check that the file does not exist yet.\n", name);
3450
"Setting log file size to %lu %lu\n",
3451
(ulong) ut_get_high32(log_file_size),
3452
(ulong) log_file_size & 0xFFFFFFFFUL);
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);
3454
3419
success = os_file_set_size(name, log_file,
3455
3420
log_file_size & 0xFFFFFFFFUL,
3456
3421
ut_get_high32(log_file_size));
3460
"InnoDB: Cannot set %s size to %lu %lu\n",
3461
name, (ulong) ut_get_high32(log_file_size),
3462
(ulong) (log_file_size & 0xFFFFFFFFUL));
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));
3466
3431
os_file_flush(log_file);
3480
3445
name, OS_FILE_OPEN,
3481
3446
OS_FILE_READ_WRITE, &success);
3482
3447
if (!success) {
3483
fprintf(stderr, "InnoDB: Cannot open %s.\n", name);
3448
drizzled::errmsg_printf(drizzled::error::ERROR, "InnoDB: Cannot open %s.\n", name);
3488
3453
os_file_write(name, log_file, buf, 0, 0,
3489
3454
LOG_FILE_HDR_SIZE + OS_FILE_LOG_BLOCK_SIZE);
3563
3528
ut_a(file_size_high == 0);
3565
fprintf(stderr, "InnoDB: Opened archived log file %s\n", name);
3530
drizzled::errmsg_printf(drizzled::error::INFO,
3531
"InnoDB: Opened archived log file %s\n", name);
3567
3533
ret = os_file_close(file_handle);
3569
3535
if (file_size < LOG_FILE_HDR_SIZE) {
3571
"InnoDB: Archive file header incomplete %s\n", name);
3536
drizzled::errmsg_printf(drizzled::error::ERROR,
3537
"InnoDB: Archive file header incomplete %s\n", name);
3592
3558
if (mach_read_from_4(buf + LOG_GROUP_ID) != group->id
3593
3559
|| mach_read_from_4(buf + LOG_FILE_NO)
3594
3560
!= group->archived_file_no) {
3561
drizzled::errmsg_printf(drizzled::error::ERROR,
3596
3562
"InnoDB: Archive file header inconsistent %s\n", name);
3601
3567
if (!mach_read_from_4(buf + LOG_FILE_ARCH_COMPLETED)) {
3568
drizzled::errmsg_printf(drizzled::error::ERROR,
3603
3569
"InnoDB: Archive file not completely written %s\n",
3612
3578
if (!recv_sys->scanned_lsn) {
3614
3580
if (recv_sys->parse_start_lsn < start_lsn) {
3616
"InnoDB: Archive log file %s"
3617
" starts from too big a lsn\n",
3581
drizzled::errmsg_printf(drizzled::error::ERROR,
3582
"InnoDB: Archive log file %s starts from too big a lsn\n", name);
3622
3586
recv_sys->scanned_lsn = start_lsn;
3625
3589
if (recv_sys->scanned_lsn != start_lsn) {
3628
"InnoDB: Archive log file %s starts from"
3591
drizzled::errmsg_printf(drizzled::error::ERROR,
3592
"InnoDB: Archive log file %s starts from a wrong lsn\n", name);
3634
3596
read_offset = LOG_FILE_HDR_SIZE;
3649
3611
#ifdef UNIV_DEBUG
3650
3612
if (log_debug_writes) {
3652
"InnoDB: Archive read starting at"
3653
" lsn %"PRIu64", len %lu from file %s\n",
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
3617
#endif /* UNIV_DEBUG */