~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

Merge Monty - Added inter-plugin dependencies for controlling plugin load order

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
 
 
66
63
#include "ut0mem.h"
67
64
#include "ut0ut.h"
68
65
#include "os0proc.h"
355
352
reading of a disk page */
356
353
UNIV_INTERN ulint srv_buf_pool_reads = 0;
357
354
 
358
 
/** Time in seconds between automatic buffer pool dumps */
359
 
UNIV_INTERN uint srv_auto_lru_dump = 0;
360
 
 
361
355
/* structure to pass status variables to MySQL */
362
356
UNIV_INTERN export_struc export_vars;
363
357
 
436
430
 
437
431
UNIV_INTERN ulong       srv_replication_delay           = 0;
438
432
 
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
 
 
458
433
/*-------------------------------------------*/
459
434
UNIV_INTERN ulong       srv_n_spin_wait_rounds  = 30;
460
435
UNIV_INTERN ulong       srv_n_free_tickets_to_enter = 500;
513
488
#ifdef UNIV_PFS_MUTEX
514
489
/* Key to register kernel_mutex with performance schema */
515
490
UNIV_INTERN mysql_pfs_key_t     kernel_mutex_key;
516
 
/* Key to protect writing the commit_id to the sys header */
517
 
UNIV_INTERN mysql_pfs_key_t     commit_id_mutex_key;
518
491
/* Key to register srv_innodb_monitor_mutex with performance schema */
519
492
UNIV_INTERN mysql_pfs_key_t     srv_innodb_monitor_mutex_key;
520
493
/* Key to register srv_monitor_file_mutex with performance schema */
773
746
UNIV_INTERN byte        srv_pad1[64];
774
747
/* mutex protecting the server, trx structs, query threads, and lock table */
775
748
UNIV_INTERN mutex_t*    kernel_mutex_temp;
776
 
/* mutex protecting the sys header for writing the commit id */
777
 
UNIV_INTERN mutex_t*    commit_id_mutex_temp;
778
 
 
779
749
/* padding to prevent other memory update hotspots from residing on
780
750
the same memory cache line */
781
751
UNIV_INTERN byte        srv_pad2[64];
1053
1023
        kernel_mutex_temp = static_cast<ib_mutex_t *>(mem_alloc(sizeof(mutex_t)));
1054
1024
        mutex_create(kernel_mutex_key, &kernel_mutex, SYNC_KERNEL);
1055
1025
 
1056
 
        commit_id_mutex_temp = static_cast<ib_mutex_t *>(mem_alloc(sizeof(mutex_t)));
1057
 
        mutex_create(commit_id_mutex_key, &commit_id_mutex, SYNC_COMMIT_ID_LOCK);
1058
 
 
1059
1026
        mutex_create(srv_innodb_monitor_mutex_key,
1060
1027
                     &srv_innodb_monitor_mutex, SYNC_NO_ORDER_CHECK);
1061
1028
 
1144
1111
        mem_free(srv_mysql_table);
1145
1112
        srv_mysql_table = NULL;
1146
1113
 
1147
 
        mem_free(commit_id_mutex_temp);
1148
 
        commit_id_mutex_temp = NULL;
1149
 
 
1150
1114
        trx_i_s_cache_free(trx_i_s_cache);
1151
1115
}
1152
1116
 
2420
2384
        new_lsn = log_get_lsn();
2421
2385
 
2422
2386
        if (new_lsn < old_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);
 
2387
                ut_print_timestamp(stderr);
 
2388
                fprintf(stderr,
 
2389
                        "  InnoDB: Error: old log sequence number %"PRIu64""
 
2390
                        " was greater\n"
 
2391
                        "InnoDB: than the new log sequence number %"PRIu64"!\n"
 
2392
                        "InnoDB: Please submit a bug report"
 
2393
                        " to http://bugs.mysql.com\n",
 
2394
                        old_lsn, new_lsn);
2427
2395
        }
2428
2396
 
2429
2397
        old_lsn = new_lsn;
2489
2457
        OS_THREAD_DUMMY_RETURN;
2490
2458
}
2491
2459
 
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
 
 
2542
2460
/**********************************************************************//**
2543
2461
Check whether any background thread is active.
2544
2462
@return FALSE if all are are suspended or have exited. */
2711
2629
        ulint           n_pages_purged  = 0;
2712
2630
        ulint           n_bytes_merged;
2713
2631
        ulint           n_pages_flushed;
2714
 
        uint32_t        n_pages_flushed_prev = 0;
2715
2632
        ulint           n_bytes_archived;
2716
2633
        ulint           n_tables_to_drop;
2717
2634
        ulint           n_ios;
2719
2636
        ulint           n_ios_very_old;
2720
2637
        ulint           n_pend_ios;
2721
2638
        ulint           next_itr_time;
2722
 
        uint32_t        prev_adaptive_flushing_method = ULINT32_UNDEFINED;
2723
 
        uint32_t        inner_loop = 0;
2724
 
        bool            skip_sleep = false;
2725
2639
        ulint           i;
2726
2640
 
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
 
 
2737
2641
#ifdef UNIV_DEBUG_THREAD_CREATION
2738
2642
        fprintf(stderr, "Master thread starts, id %lu\n",
2739
2643
                os_thread_pf(os_thread_get_curr_id()));
2754
2658
 
2755
2659
        mutex_exit(&kernel_mutex);
2756
2660
 
2757
 
        mutex_enter(&(log_sys->mutex));
2758
 
        lsn_old = log_sys->lsn;
2759
 
        mutex_exit(&(log_sys->mutex));
2760
2661
loop:
2761
2662
        /*****************************************************************/
2762
2663
        /* ---- When there is database activity by users, we cycle in this
2787
2688
        /* Sleep for 1 second on entrying the for loop below the first time. */
2788
2689
        next_itr_time = ut_time_ms() + 1000;
2789
2690
 
2790
 
        skip_sleep = false;
2791
 
 
2792
2691
        for (i = 0; i < 10; i++) {
2793
2692
                ulint   cur_time = ut_time_ms();
2794
2693
 
2795
 
                n_pages_flushed = 0;
2796
 
 
2797
2694
                /* ALTER TABLE in MySQL requires on Unix that the table handler
2798
2695
                can drop tables lazily after there no longer are SELECT
2799
2696
                queries to them. */
2817
2714
                srv_main_thread_op_info = "sleeping";
2818
2715
                srv_main_1_second_loops++;
2819
2716
 
2820
 
                if (skip_sleep == false) {
2821
 
                    if (next_itr_time > cur_time
2822
 
                        && srv_shutdown_state == SRV_SHUTDOWN_NONE) {
 
2717
                if (next_itr_time > cur_time
 
2718
                    && srv_shutdown_state == SRV_SHUTDOWN_NONE) {
2823
2719
 
2824
2720
                        /* Get sleep interval in micro seconds. We use
2825
 
                           ut_min() to avoid long sleep in case of
2826
 
                           wrap around. */
 
2721
                        ut_min() to avoid long sleep in case of
 
2722
                        wrap around. */
2827
2723
                        os_thread_sleep(ut_min(1000000,
2828
 
                                               (next_itr_time - cur_time)
2829
 
                                               * 1000));
 
2724
                                        (next_itr_time - cur_time)
 
2725
                                         * 1000));
2830
2726
                        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;
2850
2727
                }
2851
2728
 
2852
 
                skip_sleep = false;
 
2729
                /* Each iteration should happen at 1 second interval. */
 
2730
                next_itr_time = ut_time_ms() + 1000;
2853
2731
 
2854
2732
                /* Flush logs if needed */
2855
2733
                srv_sync_log_buffer_in_background();
2869
2747
                if (n_pend_ios < SRV_PEND_IO_THRESHOLD
2870
2748
                    && (n_ios - n_ios_old < SRV_RECENT_IO_ACTIVITY)) {
2871
2749
                        srv_main_thread_op_info = "doing insert buffer merge";
2872
 
                        ibuf_contract_for_n_pages(FALSE, PCT_IBUF_IO(5));
 
2750
                        ibuf_contract_for_n_pages(FALSE, PCT_IO(5));
2873
2751
 
2874
2752
                        /* Flush logs if needed */
2875
2753
                        srv_sync_log_buffer_in_background();
2886
2764
                        n_pages_flushed = buf_flush_list(
2887
2765
                                PCT_IO(100), IB_ULONGLONG_MAX);
2888
2766
 
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) {
 
2767
                } else if (srv_adaptive_flushing) {
2895
2768
 
2896
2769
                        /* Try to keep the rate of flushing of dirty
2897
2770
                        pages such that redo log generation does not
2907
2780
                                                n_flush,
2908
2781
                                                IB_ULONGLONG_MAX);
2909
2782
                        }
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;
3128
2783
                }
3129
2784
 
3130
2785
                if (srv_activity_count == old_activity_count) {
3173
2828
        even if the server were active */
3174
2829
 
3175
2830
        srv_main_thread_op_info = "doing insert buffer merge";
3176
 
        ibuf_contract_for_n_pages(FALSE, PCT_IBUF_IO(5));
 
2831
        ibuf_contract_for_n_pages(FALSE, PCT_IO(5));
3177
2832
 
3178
2833
        /* Flush logs if needed */
3179
2834
        srv_sync_log_buffer_in_background();
3281
2936
                buf_flush_list below. Otherwise, the system favors
3282
2937
                clean pages over cleanup throughput. */
3283
2938
                n_bytes_merged = ibuf_contract_for_n_pages(FALSE,
3284
 
                                                           PCT_IBUF_IO(100));
 
2939
                                                           PCT_IO(100));
3285
2940
        }
3286
2941
 
3287
2942
        srv_main_thread_op_info = "reserving kernel mutex";
3430
3085
        srv_slot_t*     slot;
3431
3086
        ulint           slot_no = ULINT_UNDEFINED;
3432
3087
        ulint           n_total_purged = ULINT_UNDEFINED;
3433
 
        ulint           next_itr_time;
3434
3088
 
3435
3089
        ut_a(srv_n_purge_threads == 1);
3436
3090
 
3449
3103
 
3450
3104
        mutex_exit(&kernel_mutex);
3451
3105
 
3452
 
        next_itr_time = ut_time_ms();
3453
 
 
3454
3106
        while (srv_shutdown_state != SRV_SHUTDOWN_EXIT_THREADS) {
3455
3107
 
3456
3108
                ulint   n_pages_purged;
3457
 
                ulint   cur_time;
3458
3109
 
3459
3110
                /* If there are very few records to purge or the last
3460
3111
                purge didn't purge any records then wait for activity.
3495
3146
                } while (n_pages_purged > 0 && !srv_fast_shutdown);
3496
3147
 
3497
3148
                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
 
                }
3508
3149
        }
3509
3150
 
3510
3151
        mutex_enter(&kernel_mutex);