~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/innobase/log/log0recv.c

  • Committer: Stewart Smith
  • Date: 2008-12-22 05:46:59 UTC
  • mto: This revision was merged to the branch mainline in revision 728.
  • Revision ID: stewart@flamingspork.com-20081222054659-q10pu3uepim0iuwn
put snowman test into main suite

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*****************************************************************************
2
 
 
3
 
Copyright (c) 1997, 2009, Innobase Oy. All Rights Reserved.
4
 
 
5
 
This program is free software; you can redistribute it and/or modify it under
6
 
the terms of the GNU General Public License as published by the Free Software
7
 
Foundation; version 2 of the License.
8
 
 
9
 
This program is distributed in the hope that it will be useful, but WITHOUT
10
 
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11
 
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12
 
 
13
 
You should have received a copy of the GNU General Public License along with
14
 
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
15
 
Place, Suite 330, Boston, MA 02111-1307 USA
16
 
 
17
 
*****************************************************************************/
18
 
 
19
1
/******************************************************
20
2
Recovery
21
3
 
 
4
(c) 1997 Innobase Oy
 
5
 
22
6
Created 9/20/1997 Heikki Tuuri
23
7
*******************************************************/
24
8
 
34
18
#include "buf0rea.h"
35
19
#include "srv0srv.h"
36
20
#include "srv0start.h"
 
21
#include "mtr0mtr.h"
37
22
#include "mtr0log.h"
 
23
#include "page0page.h"
38
24
#include "page0cur.h"
39
25
#include "page0zip.h"
 
26
#include "btr0btr.h"
40
27
#include "btr0cur.h"
41
28
#include "ibuf0ibuf.h"
42
29
#include "trx0undo.h"
43
30
#include "trx0rec.h"
44
31
#include "trx0roll.h"
 
32
#include "btr0cur.h"
 
33
#include "btr0cur.h"
 
34
#include "btr0cur.h"
 
35
#include "dict0boot.h"
 
36
#include "fil0fil.h"
 
37
#include "sync0sync.h"
45
38
#include "row0merge.h"
46
39
 
47
40
#ifdef UNIV_HOTBACKUP
590
583
        return(DB_SUCCESS);
591
584
}
592
585
 
593
 
#ifdef UNIV_HOTBACKUP
594
586
/***********************************************************************
595
587
Reads the checkpoint info needed in hot backup. */
596
588
UNIV_INTERN
661
653
 
662
654
        return(TRUE);
663
655
}
664
 
#endif /* UNIV_HOTBACKUP */
665
656
 
666
657
/**********************************************************
667
658
Checks the 4-byte checksum to the trailer checksum field of a log block.
699
690
        return(FALSE);
700
691
}
701
692
 
702
 
#ifdef UNIV_HOTBACKUP
703
693
/***********************************************************************
704
694
Scans the log segment and n_bytes_scanned is set to the length of valid
705
695
log scanned. */
789
779
                }
790
780
        }
791
781
}
792
 
#endif /* UNIV_HOTBACKUP */
793
782
 
794
783
/***********************************************************************
795
784
Tries to parse a single log record body and also applies it to a page if
2562
2551
the recovery and free the resources used in it. */
2563
2552
UNIV_INTERN
2564
2553
ulint
2565
 
recv_recovery_from_checkpoint_start_func(
2566
 
/*=====================================*/
 
2554
recv_recovery_from_checkpoint_start(
 
2555
/*================================*/
2567
2556
                                        /* out: error code or DB_SUCCESS */
2568
 
#ifdef UNIV_LOG_ARCHIVE
2569
2557
        ulint           type,           /* in: LOG_CHECKPOINT or LOG_ARCHIVE */
2570
2558
        ib_uint64_t     limit_lsn,      /* in: recover up to this lsn
2571
2559
                                        if possible */
2572
 
#endif /* UNIV_LOG_ARCHIVE */
2573
2560
        ib_uint64_t     min_flushed_lsn,/* in: min flushed lsn from
2574
2561
                                        data files */
2575
2562
        ib_uint64_t     max_flushed_lsn)/* in: max flushed lsn from
2585
2572
        ib_uint64_t     group_scanned_lsn;
2586
2573
        ib_uint64_t     contiguous_lsn;
2587
2574
        ib_uint64_t     archived_lsn;
 
2575
        ulint           capacity;
2588
2576
        byte*           buf;
2589
2577
        byte            log_hdr_buf[LOG_FILE_HDR_SIZE];
2590
2578
        ulint           err;
2591
2579
 
2592
 
#ifdef UNIV_LOG_ARCHIVE
2593
2580
        ut_ad(type != LOG_CHECKPOINT || limit_lsn == IB_ULONGLONG_MAX);
2594
 
# define TYPE_CHECKPOINT        (type == LOG_CHECKPOINT)
2595
 
# define LIMIT_LSN              limit_lsn
2596
 
#else /* UNIV_LOG_ARCHIVE */
2597
 
# define TYPE_CHECKPOINT        1
2598
 
# define LIMIT_LSN              IB_ULONGLONG_MAX
2599
 
#endif /* UNIV_LOG_ARCHIVE */
2600
2581
 
2601
 
        if (TYPE_CHECKPOINT) {
 
2582
        if (type == LOG_CHECKPOINT) {
2602
2583
                recv_sys_create();
2603
2584
                recv_sys_init(FALSE, buf_pool_get_curr_size());
2604
2585
        }
2614
2595
 
2615
2596
        recv_recovery_on = TRUE;
2616
2597
 
2617
 
        recv_sys->limit_lsn = LIMIT_LSN;
 
2598
        recv_sys->limit_lsn = limit_lsn;
2618
2599
 
2619
2600
        mutex_enter(&(log_sys->mutex));
2620
2601
 
2681
2662
        }
2682
2663
#endif /* UNIV_LOG_ARCHIVE */
2683
2664
 
2684
 
        if (TYPE_CHECKPOINT) {
 
2665
        if (type == LOG_CHECKPOINT) {
2685
2666
                /* Start reading the log groups from the checkpoint lsn up. The
2686
2667
                variable contiguous_lsn contains an lsn up to which the log is
2687
2668
                known to be contiguously written to all log groups. */
2696
2677
 
2697
2678
        contiguous_lsn = ut_uint64_align_down(recv_sys->scanned_lsn,
2698
2679
                                              OS_FILE_LOG_BLOCK_SIZE);
2699
 
        if (TYPE_CHECKPOINT) {
2700
 
                up_to_date_group = max_cp_group;
2701
 
#ifdef UNIV_LOG_ARCHIVE
2702
 
        } else {
2703
 
                ulint   capacity;
2704
 
 
 
2680
        if (type == LOG_ARCHIVE) {
2705
2681
                /* Try to recover the remaining part from logs: first from
2706
2682
                the logs of the archived group */
2707
2683
 
2734
2710
 
2735
2711
                group->scanned_lsn = group_scanned_lsn;
2736
2712
                up_to_date_group = group;
2737
 
#endif /* UNIV_LOG_ARCHIVE */
 
2713
        } else {
 
2714
                up_to_date_group = max_cp_group;
2738
2715
        }
2739
2716
 
2740
2717
        ut_ad(RECV_SCAN_SIZE <= log_sys->buf_size);
2741
2718
 
2742
2719
        group = UT_LIST_GET_FIRST(log_sys->log_groups);
2743
2720
 
2744
 
#ifdef UNIV_LOG_ARCHIVE
2745
2721
        if ((type == LOG_ARCHIVE) && (group == recv_sys->archive_group)) {
2746
2722
                group = UT_LIST_GET_NEXT(log_groups, group);
2747
2723
        }
2748
 
#endif /* UNIV_LOG_ARCHIVE */
2749
2724
 
2750
2725
        /* Set the flag to publish that we are doing startup scan. */
2751
 
        recv_log_scan_is_startup_type = TYPE_CHECKPOINT;
 
2726
        recv_log_scan_is_startup_type = (type == LOG_CHECKPOINT);
2752
2727
        while (group) {
2753
2728
                old_scanned_lsn = recv_sys->scanned_lsn;
2754
2729
 
2762
2737
                        up_to_date_group = group;
2763
2738
                }
2764
2739
 
2765
 
#ifdef UNIV_LOG_ARCHIVE
2766
2740
                if ((type == LOG_ARCHIVE)
2767
2741
                    && (group == recv_sys->archive_group)) {
2768
2742
                        group = UT_LIST_GET_NEXT(log_groups, group);
2769
2743
                }
2770
 
#endif /* UNIV_LOG_ARCHIVE */
2771
2744
 
2772
2745
                group = UT_LIST_GET_NEXT(log_groups, group);
2773
2746
        }
2774
2747
 
2775
2748
        /* Done with startup scan. Clear the flag. */
2776
2749
        recv_log_scan_is_startup_type = FALSE;
2777
 
        if (TYPE_CHECKPOINT) {
 
2750
        if (type == LOG_CHECKPOINT) {
2778
2751
                /* NOTE: we always do a 'recovery' at startup, but only if
2779
2752
                there is something wrong we will print a message to the
2780
2753
                user about recovery: */
2852
2825
 
2853
2826
                mutex_exit(&(log_sys->mutex));
2854
2827
 
2855
 
                if (recv_sys->recovered_lsn >= LIMIT_LSN) {
 
2828
                if (recv_sys->recovered_lsn >= limit_lsn) {
2856
2829
 
2857
2830
                        return(DB_SUCCESS);
2858
2831
                }
2915
2888
        records in the hash table can be run in background. */
2916
2889
 
2917
2890
        return(DB_SUCCESS);
2918
 
 
2919
 
#undef TYPE_CHECKPOINT
2920
 
#undef LIMIT_LSN
2921
2891
}
2922
2892
 
2923
2893
/************************************************************