~james-page/ubuntu/precise/mysql-5.5/misc-fixes

« back to all changes in this revision

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

  • Committer: Package Import Robot
  • Author(s): Marc Deslauriers
  • Date: 2012-06-11 07:34:33 UTC
  • mfrom: (1.1.6)
  • Revision ID: package-import@ubuntu.com-20120611073433-l9za2ni4ipp848y3
Tags: 5.5.24-0ubuntu0.12.04.1
* SECURITY UPDATE: Update to 5.5.24 to fix security issues (LP: #1011371)
  - http://dev.mysql.com/doc/refman/5.5/en/news-5-5-24.html

Show diffs side-by-side

added added

removed removed

Lines of Context:
2485
2485
}
2486
2486
 
2487
2487
/**********************************************************************//**
2488
 
Check whether any background thread is active.
2489
 
@return FALSE if all are are suspended or have exited. */
 
2488
Check whether any background thread is active. If so return the thread
 
2489
type
 
2490
@return ULINT_UNDEFINED if all are suspended or have exited, thread
 
2491
type if any are still active. */
2490
2492
UNIV_INTERN
2491
 
ibool
2492
 
srv_is_any_background_thread_active(void)
2493
 
/*=====================================*/
 
2493
ulint
 
2494
srv_get_active_thread_type(void)
 
2495
/*============================*/
2494
2496
{
2495
2497
        ulint   i;
2496
 
        ibool   ret = FALSE;
 
2498
        ibool   ret = ULINT_UNDEFINED;
2497
2499
 
2498
2500
        mutex_enter(&kernel_mutex);
2499
2501
 
2500
2502
        for (i = 0; i <= SRV_MASTER; ++i) {
2501
2503
                if (srv_n_threads_active[i] != 0) {
2502
 
                        ret = TRUE;
 
2504
                        ret = i;
2503
2505
                        break;
2504
2506
                }
2505
2507
        }
2509
2511
        return(ret);
2510
2512
}
2511
2513
 
 
2514
/*********************************************************************//**
 
2515
This function prints progress message every 60 seconds during server
 
2516
shutdown, for any activities that master thread is pending on. */
 
2517
static
 
2518
void
 
2519
srv_shutdown_print_master_pending(
 
2520
/*==============================*/
 
2521
        ib_time_t*      last_print_time,        /*!< last time the function
 
2522
                                                print the message */
 
2523
        ulint           n_tables_to_drop,       /*!< number of tables to
 
2524
                                                be dropped */
 
2525
        ulint           n_bytes_merged,         /*!< number of change buffer
 
2526
                                                just merged */
 
2527
        ulint           n_pages_flushed)        /*!< number of pages flushed */
 
2528
{
 
2529
        ib_time_t       current_time;
 
2530
        double          time_elapsed;
 
2531
 
 
2532
        current_time = ut_time();
 
2533
        time_elapsed = ut_difftime(current_time, *last_print_time);
 
2534
 
 
2535
        if (time_elapsed > 60) {
 
2536
                *last_print_time = ut_time();
 
2537
 
 
2538
                if (n_tables_to_drop) {
 
2539
                        ut_print_timestamp(stderr);
 
2540
                        fprintf(stderr, "  InnoDB: Waiting for "
 
2541
                                "%lu table(s) to be dropped\n",
 
2542
                                (ulong) n_tables_to_drop);
 
2543
                }
 
2544
 
 
2545
                /* Check change buffer merge, we only wait for change buffer
 
2546
                merge if it is a slow shutdown */
 
2547
                if (!srv_fast_shutdown && n_bytes_merged) {
 
2548
                        ut_print_timestamp(stderr);
 
2549
                        fprintf(stderr, "  InnoDB: Waiting for change "
 
2550
                                "buffer merge to complete\n"
 
2551
                                "  InnoDB: number of bytes of change buffer "
 
2552
                                "just merged:  %lu\n",
 
2553
                                n_bytes_merged);
 
2554
                }
 
2555
 
 
2556
                if (n_pages_flushed) {
 
2557
                        ut_print_timestamp(stderr);
 
2558
                        fprintf(stderr, "  InnoDB: Waiting for "
 
2559
                                "%lu pages to be flushed\n",
 
2560
                                (ulong) n_pages_flushed);
 
2561
                }
 
2562
        }
 
2563
}
 
2564
 
2512
2565
/*******************************************************************//**
2513
2566
Tells the InnoDB server that there has been activity in the database
2514
2567
and wakes up the master thread if it is suspended (not sleeping). Used
2664
2717
        ulint           n_pend_ios;
2665
2718
        ulint           next_itr_time;
2666
2719
        ulint           i;
 
2720
        ib_time_t       last_print_time;
2667
2721
 
2668
2722
#ifdef UNIV_DEBUG_THREAD_CREATION
2669
2723
        fprintf(stderr, "Master thread starts, id %lu\n",
2685
2739
 
2686
2740
        mutex_exit(&kernel_mutex);
2687
2741
 
 
2742
        last_print_time = ut_time();
2688
2743
loop:
2689
2744
        /*****************************************************************/
2690
2745
        /* ---- When there is database activity by users, we cycle in this
3030
3085
        */
3031
3086
        n_bytes_archived = 0;
3032
3087
 
 
3088
        /* Print progress message every 60 seconds during shutdown */
 
3089
        if (srv_shutdown_state > 0 && srv_print_verbose_log) {
 
3090
                srv_shutdown_print_master_pending(&last_print_time,
 
3091
                                                  n_tables_to_drop,
 
3092
                                                  n_bytes_merged,
 
3093
                                                  n_pages_flushed);
 
3094
        }
 
3095
 
3033
3096
        /* Keep looping in the background loop if still work to do */
3034
3097
 
3035
3098
        if (srv_fast_shutdown && srv_shutdown_state > 0) {
3048
3111
        } else if (n_tables_to_drop
3049
3112
                   + n_pages_purged + n_bytes_merged + n_pages_flushed
3050
3113
                   + n_bytes_archived != 0) {
 
3114
 
3051
3115
                /* In a 'slow' shutdown we run purge and the insert buffer
3052
3116
                merge to completion */
3053
3117