~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

Merge Stewart - Update innobase plugin to be based on innodb 1.1.4 from MySQL 5.5.8 

Show diffs side-by-side

added added

removed removed

Lines of Context:
734
734
/* Table for MySQL threads where they will be suspended to wait for locks */
735
735
UNIV_INTERN srv_slot_t* srv_mysql_table = NULL;
736
736
 
 
737
UNIV_INTERN os_event_t  srv_timeout_event;
 
738
 
 
739
UNIV_INTERN os_event_t  srv_monitor_event;
 
740
 
 
741
UNIV_INTERN os_event_t  srv_error_event;
 
742
 
737
743
UNIV_INTERN os_event_t  srv_lock_timeout_thread_event;
738
744
 
739
745
UNIV_INTERN srv_sys_t*  srv_sys = NULL;
1041
1047
                ut_a(slot->event);
1042
1048
        }
1043
1049
 
 
1050
        srv_error_event = os_event_create(NULL);
 
1051
 
 
1052
        srv_timeout_event = os_event_create(NULL);
 
1053
 
 
1054
        srv_monitor_event = os_event_create(NULL);
 
1055
 
1044
1056
        srv_lock_timeout_thread_event = os_event_create(NULL);
1045
1057
 
1046
1058
        for (i = 0; i < SRV_MASTER + 1; i++) {
2074
2086
                        /*!< in: a dummy parameter required by
2075
2087
                        os_thread_create */
2076
2088
{
 
2089
        ib_int64_t      sig_count;
2077
2090
        double          time_elapsed;
2078
2091
        time_t          current_time;
2079
2092
        time_t          last_table_monitor_time;
2092
2105
#endif
2093
2106
 
2094
2107
        UT_NOT_USED(arg);
2095
 
        srv_last_monitor_time = time(NULL);
2096
 
        last_table_monitor_time = time(NULL);
2097
 
        last_tablespace_monitor_time = time(NULL);
2098
 
        last_monitor_time = time(NULL);
 
2108
        srv_last_monitor_time = ut_time();
 
2109
        last_table_monitor_time = ut_time();
 
2110
        last_tablespace_monitor_time = ut_time();
 
2111
        last_monitor_time = ut_time();
2099
2112
        mutex_skipped = 0;
2100
2113
        last_srv_print_monitor = srv_print_innodb_monitor;
2101
2114
loop:
2102
2115
        srv_monitor_active = TRUE;
2103
2116
 
2104
2117
        /* Wake up every 5 seconds to see if we need to print
2105
 
        monitor information. */
2106
 
 
2107
 
        os_thread_sleep(5000000);
2108
 
 
2109
 
        current_time = time(NULL);
 
2118
        monitor information or if signalled at shutdown. */
 
2119
 
 
2120
        sig_count = os_event_reset(srv_monitor_event);
 
2121
 
 
2122
        os_event_wait_time_low(srv_monitor_event, 5000000, sig_count);
 
2123
 
 
2124
        current_time = ut_time();
2110
2125
 
2111
2126
        time_elapsed = difftime(current_time, last_monitor_time);
2112
2127
 
2113
2128
        if (time_elapsed > 15) {
2114
 
                last_monitor_time = time(NULL);
 
2129
                last_monitor_time = ut_time();
2115
2130
 
2116
2131
                if (srv_print_innodb_monitor) {
2117
2132
                        /* Reset mutex_skipped counter everytime
2155
2170
                if (srv_print_innodb_tablespace_monitor
2156
2171
                    && difftime(current_time,
2157
2172
                                last_tablespace_monitor_time) > 60) {
2158
 
                        last_tablespace_monitor_time = time(NULL);
 
2173
                        last_tablespace_monitor_time = ut_time();
2159
2174
 
2160
2175
                        fputs("========================"
2161
2176
                              "========================\n",
2181
2196
                if (srv_print_innodb_table_monitor
2182
2197
                    && difftime(current_time, last_table_monitor_time) > 60) {
2183
2198
 
2184
 
                        last_table_monitor_time = time(NULL);
 
2199
                        last_table_monitor_time = ut_time();
2185
2200
 
2186
2201
                        fputs("===========================================\n",
2187
2202
                              stderr);
2241
2256
        ibool           some_waits;
2242
2257
        double          wait_time;
2243
2258
        ulint           i;
 
2259
        ib_int64_t      sig_count;
2244
2260
 
2245
2261
#ifdef UNIV_PFS_THREAD
2246
2262
        pfs_register_thread(srv_lock_timeout_thread_key);
2247
2263
#endif
2248
2264
 
2249
2265
loop:
 
2266
 
2250
2267
        /* When someone is waiting for a lock, we wake up every second
2251
2268
        and check if a timeout has passed for a lock wait */
2252
2269
 
2253
 
        os_thread_sleep(1000000);
 
2270
        sig_count = os_event_reset(srv_timeout_event);
 
2271
 
 
2272
        os_event_wait_time_low(srv_timeout_event, 1000000, sig_count);
2254
2273
 
2255
2274
        srv_lock_timeout_active = TRUE;
2256
2275
 
2345
2364
        ulint           fatal_cnt       = 0;
2346
2365
        ib_uint64_t     old_lsn;
2347
2366
        ib_uint64_t     new_lsn;
 
2367
        ib_int64_t      sig_count;
2348
2368
 
2349
2369
        old_lsn = srv_start_lsn;
2350
2370
 
2420
2440
 
2421
2441
        fflush(stderr);
2422
2442
 
2423
 
        os_thread_sleep(1000000);
 
2443
        sig_count = os_event_reset(srv_error_event);
 
2444
 
 
2445
        os_event_wait_time_low(srv_error_event, 1000000, sig_count);
2424
2446
 
2425
2447
        if (srv_shutdown_state < SRV_SHUTDOWN_CLEANUP) {
2426
2448
 
2671
2693
        for (i = 0; i < 10; i++) {
2672
2694
                ulint   cur_time = ut_time_ms();
2673
2695
 
 
2696
                /* ALTER TABLE in MySQL requires on Unix that the table handler
 
2697
                can drop tables lazily after there no longer are SELECT
 
2698
                queries to them. */
 
2699
 
 
2700
                srv_main_thread_op_info = "doing background drop tables";
 
2701
 
 
2702
                row_drop_tables_for_mysql_in_background();
 
2703
 
 
2704
                srv_main_thread_op_info = "";
 
2705
 
 
2706
                if (srv_fast_shutdown && srv_shutdown_state > 0) {
 
2707
 
 
2708
                        goto background_loop;
 
2709
                }
 
2710
 
2674
2711
                buf_get_total_stat(&buf_stat);
2675
2712
 
2676
2713
                n_ios_old = log_sys->n_log_ios + buf_stat.n_pages_read
2679
2716
                srv_main_thread_op_info = "sleeping";
2680
2717
                srv_main_1_second_loops++;
2681
2718
 
2682
 
                if (next_itr_time > cur_time) {
 
2719
                if (next_itr_time > cur_time
 
2720
                    && srv_shutdown_state == SRV_SHUTDOWN_NONE) {
2683
2721
 
2684
2722
                        /* Get sleep interval in micro seconds. We use
2685
2723
                        ut_min() to avoid long sleep in case of
2693
2731
                /* Each iteration should happen at 1 second interval. */
2694
2732
                next_itr_time = ut_time_ms() + 1000;
2695
2733
 
2696
 
                /* ALTER TABLE in MySQL requires on Unix that the table handler
2697
 
                can drop tables lazily after there no longer are SELECT
2698
 
                queries to them. */
2699
 
 
2700
 
                srv_main_thread_op_info = "doing background drop tables";
2701
 
 
2702
 
                row_drop_tables_for_mysql_in_background();
2703
 
 
2704
 
                srv_main_thread_op_info = "";
2705
 
 
2706
 
                if (srv_fast_shutdown && srv_shutdown_state > 0) {
2707
 
 
2708
 
                        goto background_loop;
2709
 
                }
2710
 
 
2711
2734
                /* Flush logs if needed */
2712
2735
                srv_sync_log_buffer_in_background();
2713
2736
 
2885
2908
                MySQL tries to drop a table while there are still open handles
2886
2909
                to it and we had to put it to the background drop queue.) */
2887
2910
 
2888
 
                os_thread_sleep(100000);
 
2911
                if (srv_shutdown_state == SRV_SHUTDOWN_NONE) {
 
2912
                        os_thread_sleep(100000);
 
2913
                }
2889
2914
        }
2890
2915
 
2891
2916
        if (srv_n_purge_threads == 0) {