~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/innobase/log/log0log.c

  • Committer: Andrew Hutchings
  • Date: 2010-11-09 13:38:01 UTC
  • mto: (1919.1.2 trunk)
  • mto: This revision was merged to the branch mainline in revision 1920.
  • Revision ID: andrew@linuxjedi.co.uk-20101109133801-byjzsao76346395x
Add FLUSH GLOBAL STATUS; command
Clears the global status variables for the server

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*****************************************************************************
2
2
 
3
 
Copyright (c) 1995, 2010, Innobase Oy. All Rights Reserved.
 
3
Copyright (c) 1995, 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., 51 Franklin
 
15
St, Fifth Floor, Boston, MA 02110-1301 USA
 
16
 
 
17
*****************************************************************************/
 
18
/*****************************************************************************
 
19
 
 
20
Copyright (c) 1995, 2009, Innobase Oy. All Rights Reserved.
4
21
Copyright (c) 2009, Google Inc.
5
22
 
6
23
Portions of this file contain modifications contributed and copyrighted by
82
99
/* Global log system variable */
83
100
UNIV_INTERN log_t*      log_sys = NULL;
84
101
 
85
 
#ifdef UNIV_PFS_RWLOCK
86
 
UNIV_INTERN mysql_pfs_key_t     checkpoint_lock_key;
87
 
# ifdef UNIV_LOG_ARCHIVE
88
 
UNIV_INTERN mysql_pfs_key_t     archive_lock_key;
89
 
# endif
90
 
#endif /* UNIV_PFS_RWLOCK */
91
 
 
92
 
#ifdef UNIV_PFS_MUTEX
93
 
UNIV_INTERN mysql_pfs_key_t     log_sys_mutex_key;
94
 
UNIV_INTERN mysql_pfs_key_t     log_flush_order_mutex_key;
95
 
#endif /* UNIV_PFS_MUTEX */
96
 
 
97
102
#ifdef UNIV_DEBUG
98
103
UNIV_INTERN ibool       log_do_write = TRUE;
99
104
#endif /* UNIV_DEBUG */
768
773
{
769
774
        log_sys = mem_alloc(sizeof(log_t));
770
775
 
771
 
        mutex_create(log_sys_mutex_key, &log_sys->mutex, SYNC_LOG);
772
 
 
773
 
        mutex_create(log_flush_order_mutex_key,
774
 
                     &log_sys->log_flush_order_mutex,
775
 
                     SYNC_LOG_FLUSH_ORDER);
 
776
        mutex_create(&log_sys->mutex, SYNC_LOG);
776
777
 
777
778
        mutex_enter(&(log_sys->mutex));
778
779
 
828
829
        log_sys->last_checkpoint_lsn = log_sys->lsn;
829
830
        log_sys->n_pending_checkpoint_writes = 0;
830
831
 
831
 
        rw_lock_create(checkpoint_lock_key, &log_sys->checkpoint_lock,
832
 
                       SYNC_NO_ORDER_CHECK);
 
832
        rw_lock_create(&log_sys->checkpoint_lock, SYNC_NO_ORDER_CHECK);
833
833
 
834
834
        log_sys->checkpoint_buf_ptr = mem_alloc(2 * OS_FILE_LOG_BLOCK_SIZE);
835
835
        log_sys->checkpoint_buf = ut_align(log_sys->checkpoint_buf_ptr,
845
845
 
846
846
        log_sys->n_pending_archive_ios = 0;
847
847
 
848
 
        rw_lock_create(archive_lock_key, &log_sys->archive_lock,
849
 
                       SYNC_NO_ORDER_CHECK);
 
848
        rw_lock_create(&log_sys->archive_lock, SYNC_NO_ORDER_CHECK);
850
849
 
851
850
        log_sys->archive_buf = NULL;
852
851
 
1166
1165
        buf = *(group->file_header_bufs + nth_file);
1167
1166
 
1168
1167
        mach_write_to_4(buf + LOG_GROUP_ID, group->id);
1169
 
        mach_write_to_8(buf + LOG_FILE_START_LSN, start_lsn);
 
1168
        mach_write_ull(buf + LOG_FILE_START_LSN, start_lsn);
1170
1169
 
1171
1170
        /* Wipe over possible label of ibbackup --restore */
1172
1171
        memcpy(buf + LOG_FILE_WAS_CREATED_BY_HOT_BACKUP, "    ", 4);
1655
1654
                recv_apply_hashed_log_recs(TRUE);
1656
1655
        }
1657
1656
 
1658
 
        n_pages = buf_flush_list(ULINT_MAX, new_oldest);
 
1657
        n_pages = buf_flush_batch(BUF_FLUSH_LIST, ULINT_MAX, new_oldest);
1659
1658
 
1660
1659
        if (sync) {
1661
 
                buf_flush_wait_batch_end(NULL, BUF_FLUSH_LIST);
 
1660
                buf_flush_wait_batch_end(BUF_FLUSH_LIST);
1662
1661
        }
1663
1662
 
1664
1663
        if (n_pages == ULINT_UNDEFINED) {
1769
1768
 
1770
1769
        buf = group->checkpoint_buf;
1771
1770
 
1772
 
        mach_write_to_8(buf + LOG_CHECKPOINT_NO, log_sys->next_checkpoint_no);
1773
 
        mach_write_to_8(buf + LOG_CHECKPOINT_LSN, log_sys->next_checkpoint_lsn);
 
1771
        mach_write_ull(buf + LOG_CHECKPOINT_NO, log_sys->next_checkpoint_no);
 
1772
        mach_write_ull(buf + LOG_CHECKPOINT_LSN, log_sys->next_checkpoint_lsn);
1774
1773
 
1775
1774
        mach_write_to_4(buf + LOG_CHECKPOINT_OFFSET,
1776
1775
                        log_group_calc_lsn_offset(
1790
1789
                }
1791
1790
        }
1792
1791
 
1793
 
        mach_write_to_8(buf + LOG_CHECKPOINT_ARCHIVED_LSN, archived_lsn);
 
1792
        mach_write_ull(buf + LOG_CHECKPOINT_ARCHIVED_LSN, archived_lsn);
1794
1793
#else /* UNIV_LOG_ARCHIVE */
1795
 
        mach_write_to_8(buf + LOG_CHECKPOINT_ARCHIVED_LSN, IB_ULONGLONG_MAX);
 
1794
        mach_write_ull(buf + LOG_CHECKPOINT_ARCHIVED_LSN, IB_ULONGLONG_MAX);
1796
1795
#endif /* UNIV_LOG_ARCHIVE */
1797
1796
 
1798
1797
        for (i = 0; i < LOG_MAX_N_GROUPS; i++) {
1884
1883
        ib_uint64_t     lsn;
1885
1884
 
1886
1885
        mach_write_to_4(hdr_buf + LOG_GROUP_ID, 0);
1887
 
        mach_write_to_8(hdr_buf + LOG_FILE_START_LSN, start);
 
1886
        mach_write_ull(hdr_buf + LOG_FILE_START_LSN, start);
1888
1887
 
1889
1888
        lsn = start + LOG_BLOCK_HDR_SIZE;
1890
1889
 
1896
1895
                                + (sizeof "ibbackup ") - 1));
1897
1896
        buf = hdr_buf + LOG_CHECKPOINT_1;
1898
1897
 
1899
 
        mach_write_to_8(buf + LOG_CHECKPOINT_NO, 0);
1900
 
        mach_write_to_8(buf + LOG_CHECKPOINT_LSN, lsn);
 
1898
        mach_write_ull(buf + LOG_CHECKPOINT_NO, 0);
 
1899
        mach_write_ull(buf + LOG_CHECKPOINT_LSN, lsn);
1901
1900
 
1902
1901
        mach_write_to_4(buf + LOG_CHECKPOINT_OFFSET,
1903
1902
                        LOG_FILE_HDR_SIZE + LOG_BLOCK_HDR_SIZE);
1904
1903
 
1905
1904
        mach_write_to_4(buf + LOG_CHECKPOINT_LOG_BUF_SIZE, 2 * 1024 * 1024);
1906
1905
 
1907
 
        mach_write_to_8(buf + LOG_CHECKPOINT_ARCHIVED_LSN, IB_ULONGLONG_MAX);
 
1906
        mach_write_ull(buf + LOG_CHECKPOINT_ARCHIVED_LSN, IB_ULONGLONG_MAX);
1908
1907
 
1909
1908
        fold = ut_fold_binary(buf, LOG_CHECKPOINT_CHECKSUM_1);
1910
1909
        mach_write_to_4(buf + LOG_CHECKPOINT_CHECKSUM_1, fold);
2014
2013
                return(TRUE);
2015
2014
        }
2016
2015
 
2017
 
        ut_ad(log_sys->flushed_to_disk_lsn >= oldest_lsn);
 
2016
        ut_ad(log_sys->written_to_all_lsn >= oldest_lsn);
2018
2017
 
2019
2018
        if (log_sys->n_pending_checkpoint_writes > 0) {
2020
2019
                /* A checkpoint write is running */
2272
2271
        buf = *(group->archive_file_header_bufs + nth_file);
2273
2272
 
2274
2273
        mach_write_to_4(buf + LOG_GROUP_ID, group->id);
2275
 
        mach_write_to_8(buf + LOG_FILE_START_LSN, start_lsn);
 
2274
        mach_write_ull(buf + LOG_FILE_START_LSN, start_lsn);
2276
2275
        mach_write_to_4(buf + LOG_FILE_NO, file_no);
2277
2276
 
2278
2277
        mach_write_to_4(buf + LOG_FILE_ARCH_COMPLETED, FALSE);
2308
2307
        buf = *(group->archive_file_header_bufs + nth_file);
2309
2308
 
2310
2309
        mach_write_to_4(buf + LOG_FILE_ARCH_COMPLETED, TRUE);
2311
 
        mach_write_to_8(buf + LOG_FILE_END_LSN, end_lsn);
 
2310
        mach_write_ull(buf + LOG_FILE_END_LSN, end_lsn);
2312
2311
 
2313
2312
        dest_offset = nth_file * group->file_size + LOG_FILE_ARCH_COMPLETED;
2314
2313
 
2372
2371
                log_archived_file_name_gen(name, group->id,
2373
2372
                                           group->archived_file_no + n_files);
2374
2373
 
2375
 
                file_handle = os_file_create(innodb_file_log_key,
2376
 
                                             name, open_mode,
2377
 
                                             OS_FILE_AIO,
 
2374
                file_handle = os_file_create(name, open_mode, OS_FILE_AIO,
2378
2375
                                             OS_DATA_FILE, &ret);
2379
2376
 
2380
2377
                if (!ret && (open_mode == OS_FILE_CREATE)) {
2381
2378
                        file_handle = os_file_create(
2382
 
                                innodb_file_log_key, name, OS_FILE_OPEN,
2383
 
                                OS_FILE_AIO, OS_DATA_FILE, &ret);
 
2379
                                name, OS_FILE_OPEN, OS_FILE_AIO,
 
2380
                                OS_DATA_FILE, &ret);
2384
2381
                }
2385
2382
 
2386
2383
                if (!ret) {
3098
3095
 
3099
3096
        if (srv_fast_shutdown < 2
3100
3097
           && (srv_error_monitor_active
3101
 
              || srv_lock_timeout_active || srv_monitor_active)) {
 
3098
              || srv_lock_timeout_and_monitor_active)) {
3102
3099
 
3103
3100
                mutex_exit(&kernel_mutex);
3104
3101
 
3131
3128
                return; /* We SKIP ALL THE REST !! */
3132
3129
        }
3133
3130
 
 
3131
        /* Check that the master thread is suspended */
 
3132
 
 
3133
        if (srv_n_threads_active[SRV_MASTER] != 0) {
 
3134
 
 
3135
                mutex_exit(&kernel_mutex);
 
3136
 
 
3137
                goto loop;
 
3138
        }
 
3139
 
3134
3140
        mutex_exit(&kernel_mutex);
3135
3141
 
3136
 
        /* Check that the background threads are suspended */
3137
 
 
3138
 
        if (srv_is_any_background_thread_active()) {
3139
 
                goto loop;
3140
 
        }
3141
 
 
3142
3142
        mutex_enter(&(log_sys->mutex));
3143
3143
 
3144
3144
        if (log_sys->n_pending_checkpoint_writes
3196
3196
 
3197
3197
        mutex_exit(&(log_sys->mutex));
3198
3198
 
3199
 
        /* Check that the background threads stay suspended */
3200
 
        if (srv_is_any_background_thread_active()) {
 
3199
        mutex_enter(&kernel_mutex);
 
3200
        /* Check that the master thread has stayed suspended */
 
3201
        if (srv_n_threads_active[SRV_MASTER] != 0) {
3201
3202
                fprintf(stderr,
3202
 
                        "InnoDB: Warning: some background thread woke up"
 
3203
                        "InnoDB: Warning: the master thread woke up"
3203
3204
                        " during shutdown\n");
3204
3205
 
 
3206
                mutex_exit(&kernel_mutex);
 
3207
 
3205
3208
                goto loop;
3206
3209
        }
 
3210
        mutex_exit(&kernel_mutex);
3207
3211
 
3208
3212
        fil_flush_file_spaces(FIL_TABLESPACE);
3209
3213
        fil_flush_file_spaces(FIL_LOG);
3221
3225
        srv_shutdown_state = SRV_SHUTDOWN_LAST_PHASE;
3222
3226
 
3223
3227
        /* Make some checks that the server really is quiet */
3224
 
        ut_a(!srv_is_any_background_thread_active());
3225
 
 
 
3228
        ut_a(srv_n_threads_active[SRV_MASTER] == 0);
3226
3229
        ut_a(buf_all_freed());
3227
3230
        ut_a(lsn == log_sys->lsn);
3228
3231
 
3243
3246
        fil_close_all_files();
3244
3247
 
3245
3248
        /* Make some checks that the server really is quiet */
3246
 
        ut_a(!srv_is_any_background_thread_active());
3247
 
 
 
3249
        ut_a(srv_n_threads_active[SRV_MASTER] == 0);
3248
3250
        ut_a(buf_all_freed());
3249
3251
        ut_a(lsn == log_sys->lsn);
3250
3252
}
3285
3287
 
3286
3288
        ut_memcpy(scan_buf, start, end - start);
3287
3289
 
3288
 
        recv_scan_log_recs((buf_pool_get_n_pages()
3289
 
                           - (recv_n_pool_free_frames * srv_buf_pool_instances))
3290
 
                           * UNIV_PAGE_SIZE, FALSE, scan_buf, end - start,
 
3290
        recv_scan_log_recs((buf_pool->curr_size
 
3291
                            - recv_n_pool_free_frames) * UNIV_PAGE_SIZE,
 
3292
                           FALSE, scan_buf, end - start,
3291
3293
                           ut_uint64_align_down(buf_start_lsn,
3292
3294
                                                OS_FILE_LOG_BLOCK_SIZE),
3293
3295
                           &contiguous_lsn, &scanned_lsn);