~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/innobase/include/srv0srv.h

[patch 125/129] Merge patch for revision 1943 from InnoDB SVN:
revno: 1943
revision-id: svn-v4:16c675df-0fcb-4bc9-8058-dcc011a37293:branches/zip:6207
parent: svn-v4:16c675df-0fcb-4bc9-8058-dcc011a37293:branches/zip:6202
committer: vasil
timestamp: Fri 2009-11-20 08:19:14 +0000
message:
  branches/zip: Merge r6198:6206 from branches/5.1:
  
  (r6203 was skipped as it is already in branches/zip)
  
    ------------------------------------------------------------------------
    r6200 | vasil | 2009-11-19 12:14:23 +0200 (Thu, 19 Nov 2009) | 4 lines
    Changed paths:
       M /branches/5.1/btr/btr0btr.c
    
    branches/5.1:
    
    White space fixup - indent under the opening (
    
    ------------------------------------------------------------------------
    r6203 | jyang | 2009-11-19 15:12:22 +0200 (Thu, 19 Nov 2009) | 8 lines
    Changed paths:
       M /branches/5.1/btr/btr0btr.c
    
    branches/5.1: Use btr_free_root() instead of fseg_free() for
    the fix of bug #48469, because fseg_free() is not defined
    in the zip branch. And we could save one mini-trasaction started
    by fseg_free().
    
    Approved by Marko.
    
    
    ------------------------------------------------------------------------
    r6205 | jyang | 2009-11-20 07:55:48 +0200 (Fri, 20 Nov 2009) | 11 lines
    Changed paths:
       M /branches/5.1/handler/ha_innodb.cc
    
    branches/5.1: Add a special case to handle the Duplicated Key error
    and return DB_ERROR instead. This is to avoid a possible SIGSEGV
    by mysql error handling re-entering the storage layer for dup key
    info without proper table handle.
    This is to prevent a server crash when error situation in bug
    #45961 "DDL on partitioned innodb tables leaves data dictionary
    in an inconsistent state" happens.
    
    rb://157 approved by Sunny Bains.
    
    
    ------------------------------------------------------------------------
    r6206 | jyang | 2009-11-20 09:38:43 +0200 (Fri, 20 Nov 2009) | 5 lines
    Changed paths:
       M /branches/5.1/handler/ha_innodb.cc
    
    branches/5.1: Fix a minor code formating issue for 
    the parenthesis iplacement of the if condition in
    rename_table().
    
    
    ------------------------------------------------------------------------
modified:
  handler/ha_innodb.cc           2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Fhandler%2Fha_innodb.cc
diff:
=== modified file 'handler/ha_innodb.cc'

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.
4
 
Copyright (C) 2008, 2009, Google Inc.
5
 
Copyright (C) 2009, Percona Inc.
 
3
Copyright (c) 1995, 2009, Innobase Oy. All Rights Reserved.
 
4
Copyright (c) 2008, 2009, Google Inc.
6
5
 
7
6
Portions of this file contain modifications contributed and copyrighted by
8
7
Google, Inc. Those modifications are gratefully acknowledged and are described
10
9
incorporated with their permission, and subject to the conditions contained in
11
10
the file COPYING.Google.
12
11
 
13
 
Portions of this file contain modifications contributed and copyrighted
14
 
by Percona Inc.. Those modifications are
15
 
gratefully acknowledged and are described briefly in the InnoDB
16
 
documentation. The contributions by Percona Inc. are incorporated with
17
 
their permission, and subject to the conditions contained in the file
18
 
COPYING.Percona.
19
 
 
20
12
This program is free software; you can redistribute it and/or modify it under
21
13
the terms of the GNU General Public License as published by the Free Software
22
14
Foundation; version 2 of the License.
30
22
St, Fifth Floor, Boston, MA 02110-1301 USA
31
23
 
32
24
*****************************************************************************/
 
25
/***********************************************************************
 
26
 
 
27
Copyright (c) 1995, 2009, Innobase Oy. All Rights Reserved.
 
28
Copyright (c) 2009, Percona Inc.
 
29
 
 
30
Portions of this file contain modifications contributed and copyrighted
 
31
by Percona Inc.. Those modifications are
 
32
gratefully acknowledged and are described briefly in the InnoDB
 
33
documentation. The contributions by Percona Inc. are incorporated with
 
34
their permission, and subject to the conditions contained in the file
 
35
COPYING.Percona.
 
36
 
 
37
This program is free software; you can redistribute it and/or modify it
 
38
under the terms of the GNU General Public License as published by the
 
39
Free Software Foundation; version 2 of the License.
 
40
 
 
41
This program is distributed in the hope that it will be useful, but
 
42
WITHOUT ANY WARRANTY; without even the implied warranty of
 
43
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
 
44
Public License for more details.
 
45
 
 
46
You should have received a copy of the GNU General Public License along
 
47
with this program; if not, write to the Free Software Foundation, Inc.,
 
48
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
 
49
 
 
50
***********************************************************************/
33
51
 
34
52
/**************************************************//**
35
53
@file include/srv0srv.h
48
66
#include "que0types.h"
49
67
#include "trx0types.h"
50
68
 
51
 
#include <string>
52
 
 
53
69
extern const char*      srv_main_thread_op_info;
54
70
 
55
71
/** Prefix used by MySQL to indicate pre-5.1 table name encoding */
56
 
/** LOOKIE HERE!!!! This used to be srv_mysql50_table_name_prefix[10]
57
 
    which was a buffer overrun, because it didn't allow for the trailing
58
 
    '\0'. Thanks C++! */
59
 
static const std::string srv_mysql50_table_name_prefix("#mysql50#");
 
72
extern const char       srv_mysql50_table_name_prefix[9];
60
73
 
61
74
/* When this event is set the lock timeout and InnoDB monitor
62
75
thread starts running */
63
76
extern os_event_t       srv_lock_timeout_thread_event;
64
77
 
65
 
/* The monitor thread waits on this event. */
66
 
extern os_event_t       srv_monitor_event;
67
 
 
68
 
/* The lock timeout thread waits on this event. */
69
 
extern os_event_t       srv_timeout_event;
70
 
 
71
 
/* The error monitor thread waits on this event. */
72
 
extern os_event_t       srv_error_event;
73
 
 
74
78
/* If the last data file is auto-extended, we add this many pages to it
75
79
at a time */
76
80
#define SRV_AUTO_EXTEND_INCREMENT       \
115
119
/** Whether to check file format during startup.  A value of
116
120
DICT_TF_FORMAT_MAX + 1 means no checking ie. FALSE.  The default is to
117
121
set it to the highest format we support. */
118
 
extern ulint    srv_max_file_format_at_startup;
 
122
extern ulint    srv_check_file_format_at_startup;
119
123
/** Place locks to records only i.e. do not use next-key locking except
120
124
on duplicate key checking and foreign key checking */
121
125
extern ibool    srv_locks_unsafe_for_binlog;
122
126
#endif /* !UNIV_HOTBACKUP */
123
127
 
124
 
/* If this flag is TRUE, then we will use the native aio of the
125
 
OS (provided we compiled Innobase with it in), otherwise we will
126
 
use simulated aio we build below with threads.
127
 
Currently we support native aio on windows and linux */
128
 
extern my_bool  srv_use_native_aio;
129
 
#ifdef __WIN__
130
 
extern ibool    srv_use_native_conditions;
131
 
#endif
132
128
extern ulint    srv_n_data_files;
133
129
extern char**   srv_data_file_names;
134
130
extern ulint*   srv_data_file_sizes;
164
160
# endif /* UNIV_HOTBACKUP */
165
161
#endif /* BUILD_DRIZZLE */
166
162
extern ulint    srv_buf_pool_size;      /*!< requested size in bytes */
167
 
extern ulint    srv_buf_pool_instances; /*!< requested number of buffer pool instances */
168
163
extern ulint    srv_buf_pool_old_size;  /*!< previously requested size */
169
164
extern ulint    srv_buf_pool_curr_size; /*!< current size in bytes */
170
165
extern ulint    srv_mem_pool_size;
183
178
#define PCT_IO(p) ((ulong) (srv_io_capacity * ((double) p / 100.0)))
184
179
 
185
180
#ifdef UNIV_LOG_ARCHIVE
186
 
extern ibool            srv_log_archive_on;
187
 
extern ibool            srv_archive_recovery;
188
 
extern ib_uint64_t      srv_archive_recovery_limit_lsn;
 
181
extern ibool    srv_log_archive_on;
 
182
extern ibool    srv_archive_recovery;
 
183
extern dulint   srv_archive_recovery_limit_lsn;
189
184
#endif /* UNIV_LOG_ARCHIVE */
190
185
 
191
186
extern char*    srv_file_flush_method_str;
234
229
extern ibool    srv_print_verbose_log;
235
230
extern ibool    srv_print_innodb_table_monitor;
236
231
 
237
 
extern ibool    srv_lock_timeout_active;
238
 
extern ibool    srv_monitor_active;
 
232
extern ibool    srv_lock_timeout_and_monitor_active;
239
233
extern ibool    srv_error_monitor_active;
240
234
 
241
235
extern ulong    srv_n_spin_wait_rounds;
244
238
extern ulong    srv_spin_wait_delay;
245
239
extern ibool    srv_priority_boost;
246
240
 
247
 
extern ulint    srv_truncated_status_writes;
248
241
 
249
242
#ifdef UNIV_DEBUG
250
243
extern  ibool   srv_print_thread_releases;
268
261
                                query threads, and lock table: we allocate
269
262
                                it from dynamic memory to get it to the
270
263
                                same DRAM page as other hotspot semaphores */
271
 
extern mutex_t* commit_id_mutex_temp;
272
 
 
273
264
#define kernel_mutex (*kernel_mutex_temp)
274
 
#define commit_id_mutex (*commit_id_mutex_temp)
275
265
 
276
266
#define SRV_MAX_N_IO_THREADS    130
277
267
 
296
286
log buffer and have to flush it */
297
287
extern ulint srv_log_waits;
298
288
 
299
 
/* the number of purge threads to use from the worker pool (currently 0 or 1) */
300
 
extern ulong srv_n_purge_threads;
301
 
 
302
 
/* the number of records to purge in one batch */
303
 
extern ulong srv_purge_batch_size;
304
 
 
305
289
/* variable that counts amount of data read in total (in bytes) */
306
290
extern ulint srv_data_read;
307
291
 
343
327
 
344
328
/** The server system */
345
329
extern srv_sys_t*       srv_sys;
346
 
 
347
 
# ifdef UNIV_PFS_THREAD
348
 
/* Keys to register InnoDB threads with performance schema */
349
 
extern mysql_pfs_key_t  trx_rollback_clean_thread_key;
350
 
extern mysql_pfs_key_t  io_handler_thread_key;
351
 
extern mysql_pfs_key_t  srv_lock_timeout_thread_key;
352
 
extern mysql_pfs_key_t  srv_error_monitor_thread_key;
353
 
extern mysql_pfs_key_t  srv_monitor_thread_key;
354
 
extern mysql_pfs_key_t  srv_master_thread_key;
355
 
 
356
 
/* This macro register the current thread and its key with performance
357
 
schema */
358
 
#  define pfs_register_thread(key)                      \
359
 
do {                                                            \
360
 
        if (PSI_server) {                                       \
361
 
                struct PSI_thread* psi = PSI_server->new_thread(key, NULL, 0);\
362
 
                if (psi) {                                      \
363
 
                        PSI_server->set_thread(psi);            \
364
 
                }                                               \
365
 
        }                                                       \
366
 
} while (0)
367
 
 
368
 
/* This macro delist the current thread from performance schema */
369
 
#  define pfs_delete_thread()                           \
370
 
do {                                                            \
371
 
        if (PSI_server) {                                       \
372
 
                PSI_server->delete_current_thread();            \
373
 
        }                                                       \
374
 
} while (0)
375
 
# endif /* UNIV_PFS_THREAD */
376
 
 
377
330
#endif /* !UNIV_HOTBACKUP */
378
331
 
379
332
/** Types of raw partitions in innodb_data_file_path */
514
467
        void*   arg);   /*!< in: a dummy parameter required by
515
468
                        os_thread_create */
516
469
/*******************************************************************//**
517
 
Wakes up the purge thread if it's not already awake. */
518
 
UNIV_INTERN
519
 
void
520
 
srv_wake_purge_thread(void);
521
 
/*=======================*/
522
 
/*******************************************************************//**
523
470
Tells the Innobase server that there has been activity in the database
524
471
and wakes up the master thread if it is suspended (not sleeping). Used
525
472
in the MySQL interface. Note that there is a small chance that the master
535
482
void
536
483
srv_wake_master_thread(void);
537
484
/*========================*/
538
 
/*******************************************************************//**
539
 
Tells the purge thread that there has been activity in the database
540
 
and wakes up the purge thread if it is suspended (not sleeping).  Note
541
 
that there is a small chance that the purge thread stays suspended
542
 
(we do not protect our operation with the kernel mutex, for
543
 
performace reasons). */
544
 
UNIV_INTERN
545
 
void
546
 
srv_wake_purge_thread_if_not_active(void);
547
 
/*=====================================*/
548
485
/*********************************************************************//**
549
486
Puts an OS thread to wait if there are too many concurrent threads
550
487
(>= srv_thread_concurrency) inside InnoDB. The threads wait in a FIFO queue. */
603
540
                                MySQL OS thread  */
604
541
/*********************************************************************//**
605
542
A thread which wakes up threads whose lock wait may have lasted too long.
 
543
This also prints the info output by various InnoDB monitors.
606
544
@return a dummy parameter */
607
545
UNIV_INTERN
608
546
os_thread_ret_t
609
 
srv_lock_timeout_thread(
610
 
/*====================*/
 
547
srv_lock_timeout_and_monitor_thread(
 
548
/*================================*/
611
549
        void*   arg);   /*!< in: a dummy parameter required by
612
550
                        os_thread_create */
613
551
/*********************************************************************//**
614
 
A thread which prints the info output by various InnoDB monitors.
615
 
@return a dummy parameter */
616
 
UNIV_INTERN
617
 
os_thread_ret_t
618
 
srv_monitor_thread(
619
 
/*===============*/
620
 
        void*   arg);   /*!< in: a dummy parameter required by
621
 
                        os_thread_create */
622
 
/*************************************************************************
623
552
A thread which prints warnings about semaphore waits which have lasted
624
553
too long. These can be used to track bugs which cause hangs.
625
554
@return a dummy parameter */
630
559
        void*   arg);   /*!< in: a dummy parameter required by
631
560
                        os_thread_create */
632
561
/******************************************************************//**
633
 
Outputs to a file the output of the InnoDB Monitor.
634
 
@return FALSE if not all information printed
635
 
due to failure to obtain necessary mutex */
 
562
Outputs to a file the output of the InnoDB Monitor. */
636
563
UNIV_INTERN
637
 
ibool
 
564
void
638
565
srv_printf_innodb_monitor(
639
566
/*======================*/
640
567
        FILE*   file,           /*!< in: output stream */
641
 
        ibool   nowait,         /*!< in: whether to wait for kernel mutex */
642
568
        ulint*  trx_start,      /*!< out: file position of the start of
643
569
                                the list of active transactions */
644
570
        ulint*  trx_end);       /*!< out: file position of the end of
651
577
srv_export_innodb_status(void);
652
578
/*==========================*/
653
579
 
654
 
/******************************************************************//**
655
 
Increment the server activity counter. */
656
 
UNIV_INTERN
657
 
void
658
 
srv_inc_activity_count(void);
659
 
/*=========================*/
660
 
 
661
 
/*********************************************************************//**
662
 
Asynchronous purge thread.
663
 
@return a dummy parameter */
664
 
UNIV_INTERN
665
 
os_thread_ret_t
666
 
srv_purge_thread(
667
 
/*=============*/
668
 
        void*   /*arg __attribute__((unused))*/); /*!< in: a dummy parameter
669
 
                                              required by os_thread_create */
670
 
 
671
 
/**********************************************************************//**
672
 
Enqueues a task to server task queue and releases a worker thread, if there
673
 
is a suspended one. */
674
 
UNIV_INTERN
675
 
void
676
 
srv_que_task_enqueue_low(
677
 
/*=====================*/
678
 
        que_thr_t*      thr);   /*!< in: query thread */
679
 
 
680
 
/**********************************************************************//**
681
 
Check whether any background thread is active.
682
 
@return FALSE if all are are suspended or have exited. */
683
 
UNIV_INTERN
684
 
ibool
685
 
srv_is_any_background_thread_active(void);
686
 
/*======================================*/
 
580
/** Thread slot in the thread table */
 
581
typedef struct srv_slot_struct  srv_slot_t;
 
582
 
 
583
/** Thread table is an array of slots */
 
584
typedef srv_slot_t      srv_table_t;
687
585
 
688
586
/** Status variables to be passed to MySQL */
689
587
struct export_var_struct{
737
635
        ulint innodb_rows_inserted;             /*!< srv_n_rows_inserted */
738
636
        ulint innodb_rows_updated;              /*!< srv_n_rows_updated */
739
637
        ulint innodb_rows_deleted;              /*!< srv_n_rows_deleted */
740
 
        ulint innodb_truncated_status_writes;   /*!< srv_truncated_status_writes */
741
638
};
742
639
 
743
 
/** Thread slot in the thread table */
744
 
typedef struct srv_slot_struct  srv_slot_t;
745
 
 
746
 
/** Thread table is an array of slots */
747
 
typedef srv_slot_t      srv_table_t;
748
 
 
749
640
/** The server system struct */
750
641
struct srv_sys_struct{
751
642
        srv_table_t*    threads;        /*!< server thread table */
754
645
};
755
646
 
756
647
extern ulint    srv_n_threads_active[];
 
648
 
757
649
#else /* !UNIV_HOTBACKUP */
 
650
# define srv_use_checksums                      TRUE
758
651
# define srv_use_adaptive_hash_indexes          FALSE
759
 
# define srv_use_checksums                      TRUE
760
 
# define srv_use_native_aio                     FALSE
761
652
# define srv_force_recovery                     0UL
762
653
# define srv_set_io_thread_op_info(t,info)      ((void) 0)
763
654
# define srv_is_being_started                   0