~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/innobase/srv/srv0srv.cc

  • Committer: Olaf van der Spek
  • Date: 2011-07-04 19:11:47 UTC
  • mto: This revision was merged to the branch mainline in revision 2367.
  • Revision ID: olafvdspek@gmail.com-20110704191147-s99ojek811zi1fzj
RemoveĀ unusedĀ Name_resolution_context::error_reporter

Show diffs side-by-side

added added

removed removed

Lines of Context:
60
60
/* Dummy comment */
61
61
#include "srv0srv.h"
62
62
 
 
63
#include <drizzled/error.h>
 
64
#include <drizzled/errmsg_print.h>
 
65
 
63
66
#include "ut0mem.h"
64
67
#include "ut0ut.h"
65
68
#include "os0proc.h"
352
355
reading of a disk page */
353
356
UNIV_INTERN ulint srv_buf_pool_reads = 0;
354
357
 
 
358
/** Time in seconds between automatic buffer pool dumps */
 
359
UNIV_INTERN uint srv_auto_lru_dump = 0;
 
360
 
355
361
/* structure to pass status variables to MySQL */
356
362
UNIV_INTERN export_struc export_vars;
357
363
 
430
436
 
431
437
UNIV_INTERN ulong       srv_replication_delay           = 0;
432
438
 
 
439
UNIV_INTERN uint64_t    srv_ibuf_max_size = 0;
 
440
UNIV_INTERN uint32_t    srv_ibuf_active_contract = 0;
 
441
UNIV_INTERN uint32_t    srv_ibuf_accel_rate = 100;
 
442
 
 
443
#define PCT_IBUF_IO(pct) (srv_io_capacity * srv_ibuf_accel_rate \
 
444
                          * (pct / 10000.0))
 
445
 
 
446
UNIV_INTERN uint32_t    srv_checkpoint_age_target = 0;
 
447
UNIV_INTERN uint32_t    srv_flush_neighbor_pages = 1;
 
448
 
 
449
UNIV_INTERN uint32_t    srv_read_ahead = 3; /* 1: random, 2: linear, 3: both */
 
450
UNIV_INTERN uint32_t    srv_adaptive_flushing_method = 0; /* 0: native,
 
451
                                                             1: estimate,
 
452
                                                             2: keep_average */
 
453
 
 
454
UNIV_INTERN ibool srv_read_only = FALSE;
 
455
UNIV_INTERN ibool srv_fake_write = FALSE;
 
456
UNIV_INTERN ibool srv_apply_log_only = FALSE;
 
457
 
433
458
/*-------------------------------------------*/
434
459
UNIV_INTERN ulong       srv_n_spin_wait_rounds  = 30;
435
460
UNIV_INTERN ulong       srv_n_free_tickets_to_enter = 500;
2395
2420
        new_lsn = log_get_lsn();
2396
2421
 
2397
2422
        if (new_lsn < old_lsn) {
2398
 
                ut_print_timestamp(stderr);
2399
 
                fprintf(stderr,
2400
 
                        "  InnoDB: Error: old log sequence number %"PRIu64""
2401
 
                        " was greater\n"
2402
 
                        "InnoDB: than the new log sequence number %"PRIu64"!\n"
2403
 
                        "InnoDB: Please submit a bug report"
2404
 
                        " to http://bugs.mysql.com\n",
2405
 
                        old_lsn, new_lsn);
 
2423
          drizzled::errmsg_printf(drizzled::error::INFO,
 
2424
                                  "InnoDB: Error: old log sequence number %"PRIu64" was greater than the new log sequence number %"PRIu64"!"
 
2425
                                  "InnoDB: Please submit a bug report to http://bugs.launchpad.net/drizzle",
 
2426
                                  old_lsn, new_lsn);
2406
2427
        }
2407
2428
 
2408
2429
        old_lsn = new_lsn;
2468
2489
        OS_THREAD_DUMMY_RETURN;
2469
2490
}
2470
2491
 
 
2492
/*********************************************************************//**
 
2493
A thread which restores the buffer pool from a dump file on startup and does
 
2494
periodic buffer pool dumps.
 
2495
@return a dummy parameter */
 
2496
UNIV_INTERN
 
2497
os_thread_ret_t
 
2498
srv_LRU_dump_restore_thread(
 
2499
/*====================*/
 
2500
        void*   /*arg __attribute__((unused))*/)
 
2501
/*!< in: a dummy parameter required by
 
2502
os_thread_create */
 
2503
{
 
2504
        uint    auto_lru_dump;
 
2505
        time_t  last_dump_time;
 
2506
        time_t  time_elapsed;
 
2507
 
 
2508
#ifdef UNIV_DEBUG_THREAD_CREATION
 
2509
        fprintf(stderr, "The LRU dump/restore thread has started, id %lu\n",
 
2510
                os_thread_pf(os_thread_get_curr_id()));
 
2511
#endif
 
2512
 
 
2513
        if (srv_auto_lru_dump)
 
2514
                buf_LRU_file_restore();
 
2515
 
 
2516
        last_dump_time = time(NULL);
 
2517
 
 
2518
loop:
 
2519
        os_thread_sleep(5000000);
 
2520
 
 
2521
        if (srv_shutdown_state >= SRV_SHUTDOWN_CLEANUP) {
 
2522
                goto exit_func;
 
2523
        }
 
2524
 
 
2525
        time_elapsed = time(NULL) - last_dump_time;
 
2526
        auto_lru_dump = srv_auto_lru_dump;
 
2527
        if (auto_lru_dump > 0 && (time_t) auto_lru_dump < time_elapsed) {
 
2528
                last_dump_time = time(NULL);
 
2529
                buf_LRU_file_dump();
 
2530
        }
 
2531
 
 
2532
        goto loop;
 
2533
exit_func:
 
2534
        /* We count the number of threads in os_thread_exit(). A created
 
2535
        thread should always use that to exit and not use return() to exit. */
 
2536
 
 
2537
        os_thread_exit(NULL);
 
2538
 
 
2539
        OS_THREAD_DUMMY_RETURN;
 
2540
}
 
2541
 
2471
2542
/**********************************************************************//**
2472
2543
Check whether any background thread is active.
2473
2544
@return FALSE if all are are suspended or have exited. */
2640
2711
        ulint           n_pages_purged  = 0;
2641
2712
        ulint           n_bytes_merged;
2642
2713
        ulint           n_pages_flushed;
 
2714
        uint32_t        n_pages_flushed_prev = 0;
2643
2715
        ulint           n_bytes_archived;
2644
2716
        ulint           n_tables_to_drop;
2645
2717
        ulint           n_ios;
2647
2719
        ulint           n_ios_very_old;
2648
2720
        ulint           n_pend_ios;
2649
2721
        ulint           next_itr_time;
 
2722
        uint32_t        prev_adaptive_flushing_method = ULINT32_UNDEFINED;
 
2723
        uint32_t        inner_loop = 0;
 
2724
        bool            skip_sleep = false;
2650
2725
        ulint           i;
2651
2726
 
 
2727
        struct t_prev_flush_info_struct {
 
2728
            uint32_t    count;
 
2729
            uint32_t    space;
 
2730
            uint32_t    offset;
 
2731
            uint64_t    oldest_modification;
 
2732
        } prev_flush_info[MAX_BUFFER_POOLS];
 
2733
 
 
2734
        uint64_t        lsn_old;
 
2735
        uint64_t        oldest_lsn;
 
2736
 
2652
2737
#ifdef UNIV_DEBUG_THREAD_CREATION
2653
2738
        fprintf(stderr, "Master thread starts, id %lu\n",
2654
2739
                os_thread_pf(os_thread_get_curr_id()));
2669
2754
 
2670
2755
        mutex_exit(&kernel_mutex);
2671
2756
 
 
2757
        mutex_enter(&(log_sys->mutex));
 
2758
        lsn_old = log_sys->lsn;
 
2759
        mutex_exit(&(log_sys->mutex));
2672
2760
loop:
2673
2761
        /*****************************************************************/
2674
2762
        /* ---- When there is database activity by users, we cycle in this
2699
2787
        /* Sleep for 1 second on entrying the for loop below the first time. */
2700
2788
        next_itr_time = ut_time_ms() + 1000;
2701
2789
 
 
2790
        skip_sleep = false;
 
2791
 
2702
2792
        for (i = 0; i < 10; i++) {
2703
2793
                ulint   cur_time = ut_time_ms();
2704
2794
 
 
2795
                n_pages_flushed = 0;
 
2796
 
2705
2797
                /* ALTER TABLE in MySQL requires on Unix that the table handler
2706
2798
                can drop tables lazily after there no longer are SELECT
2707
2799
                queries to them. */
2725
2817
                srv_main_thread_op_info = "sleeping";
2726
2818
                srv_main_1_second_loops++;
2727
2819
 
2728
 
                if (next_itr_time > cur_time
2729
 
                    && srv_shutdown_state == SRV_SHUTDOWN_NONE) {
 
2820
                if (skip_sleep == false) {
 
2821
                    if (next_itr_time > cur_time
 
2822
                        && srv_shutdown_state == SRV_SHUTDOWN_NONE) {
2730
2823
 
2731
2824
                        /* Get sleep interval in micro seconds. We use
2732
 
                        ut_min() to avoid long sleep in case of
2733
 
                        wrap around. */
 
2825
                           ut_min() to avoid long sleep in case of
 
2826
                           wrap around. */
2734
2827
                        os_thread_sleep(ut_min(1000000,
2735
 
                                        (next_itr_time - cur_time)
2736
 
                                         * 1000));
 
2828
                                               (next_itr_time - cur_time)
 
2829
                                               * 1000));
2737
2830
                        srv_main_sleeps++;
 
2831
 
 
2832
                        /*
 
2833
                          TODO: tracing code unported to Drizzle
 
2834
                          mutex_enter(&(log_sys->mutex));
 
2835
                          oldest_lsn = buf_pool_get_oldest_modification();
 
2836
                          ib_uint64_t   lsn = log_sys->lsn;
 
2837
                          mutex_exit(&(log_sys->mutex));
 
2838
 
 
2839
                          if(oldest_lsn)
 
2840
                              fprintf(stderr,
 
2841
                                      "InnoDB flush: age pct: %lu, lsn progress: %lu\n",
 
2842
                                      (lsn - oldest_lsn) * 100 / log_sys->max_checkpoint_age,
 
2843
                                      lsn - lsn_old);
 
2844
                        */
 
2845
 
 
2846
                    }
 
2847
 
 
2848
                    /* Each iteration should happen at 1 second interval. */
 
2849
                    next_itr_time = ut_time_ms() + 1000;
2738
2850
                }
2739
2851
 
2740
 
                /* Each iteration should happen at 1 second interval. */
2741
 
                next_itr_time = ut_time_ms() + 1000;
 
2852
                skip_sleep = false;
2742
2853
 
2743
2854
                /* Flush logs if needed */
2744
2855
                srv_sync_log_buffer_in_background();
2758
2869
                if (n_pend_ios < SRV_PEND_IO_THRESHOLD
2759
2870
                    && (n_ios - n_ios_old < SRV_RECENT_IO_ACTIVITY)) {
2760
2871
                        srv_main_thread_op_info = "doing insert buffer merge";
2761
 
                        ibuf_contract_for_n_pages(FALSE, PCT_IO(5));
 
2872
                        ibuf_contract_for_n_pages(FALSE, PCT_IBUF_IO(5));
2762
2873
 
2763
2874
                        /* Flush logs if needed */
2764
2875
                        srv_sync_log_buffer_in_background();
2775
2886
                        n_pages_flushed = buf_flush_list(
2776
2887
                                PCT_IO(100), IB_ULONGLONG_MAX);
2777
2888
 
2778
 
                } else if (srv_adaptive_flushing) {
 
2889
                        mutex_enter(&(log_sys->mutex));
 
2890
                        lsn_old = log_sys->lsn;
 
2891
                        mutex_exit(&(log_sys->mutex));
 
2892
                        prev_adaptive_flushing_method = ULINT32_UNDEFINED;
 
2893
                } else if (srv_adaptive_flushing
 
2894
                           && srv_adaptive_flushing_method == 0) {
2779
2895
 
2780
2896
                        /* Try to keep the rate of flushing of dirty
2781
2897
                        pages such that redo log generation does not
2791
2907
                                                n_flush,
2792
2908
                                                IB_ULONGLONG_MAX);
2793
2909
                        }
 
2910
 
 
2911
                        mutex_enter(&(log_sys->mutex));
 
2912
                        lsn_old = log_sys->lsn;
 
2913
                        mutex_exit(&(log_sys->mutex));
 
2914
                        prev_adaptive_flushing_method = ULINT32_UNDEFINED;
 
2915
                } else if (srv_adaptive_flushing
 
2916
                           && srv_adaptive_flushing_method == 1) {
 
2917
 
 
2918
                        /* Try to keep modified age not to exceed
 
2919
                           max_checkpoint_age * 7/8 line */
 
2920
 
 
2921
                        mutex_enter(&(log_sys->mutex));
 
2922
 
 
2923
                        oldest_lsn = buf_pool_get_oldest_modification();
 
2924
                        if (oldest_lsn == 0) {
 
2925
                                lsn_old = log_sys->lsn;
 
2926
                                mutex_exit(&(log_sys->mutex));
 
2927
 
 
2928
                        } else {
 
2929
                                if ((log_sys->lsn - oldest_lsn)
 
2930
                                    > (log_sys->max_checkpoint_age)
 
2931
                                    - ((log_sys->max_checkpoint_age) / 8)) {
 
2932
                                        /* LOG_POOL_PREFLUSH_RATIO_ASYNC is exceeded. */
 
2933
                                        /* We should not flush from here. */
 
2934
                                        lsn_old = log_sys->lsn;
 
2935
                                        mutex_exit(&(log_sys->mutex));
 
2936
                                } else if ((log_sys->lsn - oldest_lsn)
 
2937
                                           > (log_sys->max_checkpoint_age)/4) {
 
2938
 
 
2939
                                        /* defence line (max_checkpoint_age * 1/2) */
 
2940
                                        uint64_t        lsn = log_sys->lsn;
 
2941
 
 
2942
                                        uint64_t        level, bpl;
 
2943
                                        buf_page_t*     bpage;
 
2944
                                        ulint           j;
 
2945
 
 
2946
                                        mutex_exit(&(log_sys->mutex));
 
2947
 
 
2948
                                        bpl = 0;
 
2949
 
 
2950
                                        for (j = 0; j < srv_buf_pool_instances; j++) {
 
2951
                                                buf_pool_t*     buf_pool;
 
2952
                                                uint32_t        n_blocks = 0;
 
2953
 
 
2954
                                                buf_pool = buf_pool_from_array(j);
 
2955
 
 
2956
                                                /* The scanning flush_list is optimistic here */
 
2957
 
 
2958
                                                level = 0;
 
2959
                                                bpage = UT_LIST_GET_FIRST(buf_pool->flush_list);
 
2960
 
 
2961
                                                while (bpage != NULL) {
 
2962
                                                        uint64_t        oldest_modification = bpage->oldest_modification;
 
2963
                                                        if (oldest_modification != 0) {
 
2964
                                                                level += log_sys->max_checkpoint_age
 
2965
                                                                        - (lsn - oldest_modification);
 
2966
                                                        }
 
2967
                                                        bpage = UT_LIST_GET_NEXT(list, bpage);
 
2968
                                                        n_blocks++;
 
2969
                                                }
 
2970
 
 
2971
                                                if (level) {
 
2972
                                                        bpl += ((ib_uint64_t) n_blocks * n_blocks
 
2973
                                                                * (lsn - lsn_old)) / level;
 
2974
                                                }
 
2975
 
 
2976
                                        }
 
2977
 
 
2978
                                        if (!srv_use_doublewrite_buf) {
 
2979
                                                /* flush is faster than when doublewrite */
 
2980
                                                bpl = (bpl * 7) / 8;
 
2981
                                        }
 
2982
 
 
2983
                                        if (bpl) {
 
2984
retry_flush_batch:
 
2985
                                                n_pages_flushed = buf_flush_list(bpl,
 
2986
                                                                                 oldest_lsn + (lsn - lsn_old));
 
2987
                                                if (n_pages_flushed == ULINT32_UNDEFINED) {
 
2988
                                                        os_thread_sleep(5000);
 
2989
                                                        goto retry_flush_batch;
 
2990
                                                }
 
2991
                                        }
 
2992
 
 
2993
                                        lsn_old = lsn;
 
2994
                                        /*
 
2995
                                          TODO: tracing code unported to Drizzle
 
2996
                                          fprintf(stderr,
 
2997
                                                  "InnoDB flush: age pct: %lu, lsn progress: %lu, blocks to flush:%llu\n",
 
2998
                                                  (lsn - oldest_lsn) * 100 / log_sys->max_checkpoint_age,
 
2999
                                                  lsn - lsn_old, bpl);
 
3000
                                        */
 
3001
                                } else {
 
3002
                                        lsn_old = log_sys->lsn;
 
3003
                                        mutex_exit(&(log_sys->mutex));
 
3004
                                }
 
3005
                        }
 
3006
                        prev_adaptive_flushing_method = 1;
 
3007
                } else if (srv_adaptive_flushing && srv_adaptive_flushing_method == 2) {
 
3008
                        buf_pool_t*     buf_pool;
 
3009
                        buf_page_t*     bpage;
 
3010
                        uint64_t        lsn;
 
3011
                        ulint           j;
 
3012
 
 
3013
                        mutex_enter(&(log_sys->mutex));
 
3014
                        oldest_lsn = buf_pool_get_oldest_modification();
 
3015
                        lsn = log_sys->lsn;
 
3016
                        mutex_exit(&(log_sys->mutex));
 
3017
 
 
3018
                        /* upper loop/sec. (x10) */
 
3019
                        next_itr_time -= 900; /* 1000 - 900 == 100 */
 
3020
                        inner_loop++;
 
3021
                        if (inner_loop < 10) {
 
3022
                                i--;
 
3023
                        } else {
 
3024
                                inner_loop = 0;
 
3025
                        }
 
3026
 
 
3027
                        if (prev_adaptive_flushing_method == 2) {
 
3028
                                int32_t         n_flush;
 
3029
                                int32_t         blocks_sum = 0;
 
3030
                                uint32_t        new_blocks_sum = 0;
 
3031
                                uint32_t flushed_blocks_sum = 0;
 
3032
 
 
3033
                                /* prev_flush_info[j] should be the previous loop's */
 
3034
                                for (j = 0; j < srv_buf_pool_instances; j++) {
 
3035
                                        int32_t blocks_num, new_blocks_num, flushed_blocks_num;
 
3036
                                        bool    found = false;
 
3037
 
 
3038
                                        buf_pool = buf_pool_from_array(j);
 
3039
 
 
3040
                                        blocks_num = UT_LIST_GET_LEN(buf_pool->flush_list);
 
3041
                                        bpage = UT_LIST_GET_FIRST(buf_pool->flush_list);
 
3042
                                        new_blocks_num = 0;
 
3043
 
 
3044
                                        while (bpage != NULL) {
 
3045
                                                if (prev_flush_info[j].space == bpage->space
 
3046
                                                    && prev_flush_info[j].offset == bpage->offset
 
3047
                                                    && prev_flush_info[j].oldest_modification
 
3048
                                                    == bpage->oldest_modification) {
 
3049
                                                        found = true;
 
3050
                                                        break;
 
3051
                                                }
 
3052
                                                bpage = UT_LIST_GET_NEXT(list, bpage);
 
3053
                                                new_blocks_num++;
 
3054
                                        }
 
3055
                                        if (!found) {
 
3056
                                                new_blocks_num = blocks_num;
 
3057
                                        }
 
3058
                                        flushed_blocks_num = new_blocks_num
 
3059
                                                + prev_flush_info[j].count
 
3060
                                                - blocks_num;
 
3061
                                        if (flushed_blocks_num < 0) {
 
3062
                                                flushed_blocks_num = 0;
 
3063
                                        }
 
3064
 
 
3065
                                        bpage = UT_LIST_GET_FIRST(buf_pool->flush_list);
 
3066
 
 
3067
                                        prev_flush_info[j].count = UT_LIST_GET_LEN(buf_pool->flush_list);
 
3068
                                        if (bpage) {
 
3069
                                                prev_flush_info[j].space = bpage->space;
 
3070
                                                prev_flush_info[j].offset = bpage->offset;
 
3071
                                                prev_flush_info[j].oldest_modification = bpage->oldest_modification;
 
3072
                                        } else {
 
3073
                                                prev_flush_info[j].space = 0;
 
3074
                                                prev_flush_info[j].offset = 0;
 
3075
                                                prev_flush_info[j].oldest_modification = 0;
 
3076
                                        }
 
3077
 
 
3078
                                        new_blocks_sum += new_blocks_num;
 
3079
                                        flushed_blocks_sum += flushed_blocks_num;
 
3080
                                        blocks_sum += blocks_num;
 
3081
                                }
 
3082
 
 
3083
                                n_flush = blocks_sum * (lsn - lsn_old) / log_sys->max_modified_age_async;
 
3084
                                if (flushed_blocks_sum > n_pages_flushed_prev) {
 
3085
                                        n_flush -= (flushed_blocks_sum - n_pages_flushed_prev);
 
3086
                                }
 
3087
 
 
3088
                                if (n_flush > 0) {
 
3089
                                        n_flush++;
 
3090
                                        n_pages_flushed = buf_flush_list(n_flush, oldest_lsn + (lsn - lsn_old));
 
3091
                                } else {
 
3092
                                        n_pages_flushed = 0;
 
3093
                                }
 
3094
                        } else {
 
3095
                                /* store previous first pages of the flush_list */
 
3096
                                for (j = 0; j < srv_buf_pool_instances; j++) {
 
3097
                                        buf_pool = buf_pool_from_array(j);
 
3098
 
 
3099
                                        bpage = UT_LIST_GET_FIRST(buf_pool->flush_list);
 
3100
 
 
3101
                                        prev_flush_info[j].count = UT_LIST_GET_LEN(buf_pool->flush_list);
 
3102
                                        if (bpage) {
 
3103
                                                prev_flush_info[j].space = bpage->space;
 
3104
                                                prev_flush_info[j].offset = bpage->offset;
 
3105
                                                prev_flush_info[j].oldest_modification =  bpage->oldest_modification;
 
3106
                                        } else {
 
3107
                                                prev_flush_info[j].space = 0;
 
3108
                                                prev_flush_info[j].offset = 0;
 
3109
                                                prev_flush_info[j].oldest_modification = 0;
 
3110
                                        }
 
3111
                                }
 
3112
                                n_pages_flushed = 0;
 
3113
                        }
 
3114
 
 
3115
                        lsn_old = lsn;
 
3116
                        prev_adaptive_flushing_method = 2;
 
3117
                } else {
 
3118
                        mutex_enter(&(log_sys->mutex));
 
3119
                        lsn_old = log_sys->lsn;
 
3120
                        mutex_exit(&(log_sys->mutex));
 
3121
                        prev_adaptive_flushing_method = ULINT32_UNDEFINED;
 
3122
                }
 
3123
 
 
3124
                if (n_pages_flushed == ULINT_UNDEFINED) {
 
3125
                        n_pages_flushed_prev = 0;
 
3126
                } else {
 
3127
                        n_pages_flushed_prev = n_pages_flushed;
2794
3128
                }
2795
3129
 
2796
3130
                if (srv_activity_count == old_activity_count) {
2839
3173
        even if the server were active */
2840
3174
 
2841
3175
        srv_main_thread_op_info = "doing insert buffer merge";
2842
 
        ibuf_contract_for_n_pages(FALSE, PCT_IO(5));
 
3176
        ibuf_contract_for_n_pages(FALSE, PCT_IBUF_IO(5));
2843
3177
 
2844
3178
        /* Flush logs if needed */
2845
3179
        srv_sync_log_buffer_in_background();
2947
3281
                buf_flush_list below. Otherwise, the system favors
2948
3282
                clean pages over cleanup throughput. */
2949
3283
                n_bytes_merged = ibuf_contract_for_n_pages(FALSE,
2950
 
                                                           PCT_IO(100));
 
3284
                                                           PCT_IBUF_IO(100));
2951
3285
        }
2952
3286
 
2953
3287
        srv_main_thread_op_info = "reserving kernel mutex";
3096
3430
        srv_slot_t*     slot;
3097
3431
        ulint           slot_no = ULINT_UNDEFINED;
3098
3432
        ulint           n_total_purged = ULINT_UNDEFINED;
 
3433
        ulint           next_itr_time;
3099
3434
 
3100
3435
        ut_a(srv_n_purge_threads == 1);
3101
3436
 
3114
3449
 
3115
3450
        mutex_exit(&kernel_mutex);
3116
3451
 
 
3452
        next_itr_time = ut_time_ms();
 
3453
 
3117
3454
        while (srv_shutdown_state != SRV_SHUTDOWN_EXIT_THREADS) {
3118
3455
 
3119
3456
                ulint   n_pages_purged;
 
3457
                ulint   cur_time;
3120
3458
 
3121
3459
                /* If there are very few records to purge or the last
3122
3460
                purge didn't purge any records then wait for activity.
3157
3495
                } while (n_pages_purged > 0 && !srv_fast_shutdown);
3158
3496
 
3159
3497
                srv_sync_log_buffer_in_background();
 
3498
 
 
3499
                cur_time = ut_time_ms();
 
3500
                if (next_itr_time > cur_time) {
 
3501
                        os_thread_sleep(ut_min(1000000,
 
3502
                                               (next_itr_time - cur_time)
 
3503
                                               * 1000));
 
3504
                        next_itr_time = ut_time_ms() + 1000;
 
3505
                } else {
 
3506
                        next_itr_time = cur_time + 1000;
 
3507
                }
3160
3508
        }
3161
3509
 
3162
3510
        mutex_enter(&kernel_mutex);