 branches/zip: Implement the configuration parameter and settable global
variable innodb_file_format. Implement file format version stamping of
*.ibd files and SYS_TABLES.TYPE.
This change breaks introduces an incompatible change for for
compressed tables. We can do this, as we have not released yet.
innodb-zip.test: Add tests for stricter KEY_BLOCK_SIZE and ROW_FORMAT
checks.
DICT_TF_COMPRESSED_MASK, DICT_TF_COMPRESSED_SHIFT: Replace with
DICT_TF_ZSSIZE_MASK, DICT_TF_ZSSIZE_SHIFT.
DICT_TF_FORMAT_MASK, DICT_TF_FORMAT_SHIFT, DICT_TF_FORMAT_51,
DICT_TF_FORMAT_ZIP: File format version, stored in table->flags,
in the .ibd file header, and in SYS_TABLES.TYPE.
dict_create_sys_tables_tuple(): Write the table flags to SYS_TABLES.TYPE
if the format is at least DICT_TF_FORMAT_ZIP. For old formats
(DICT_TF_FORMAT_51), write DICT_TABLE_ORDINARY as the table type.
DB_TABLE_ZIP_NO_IBD: Remove the error code. The error handling is done
in ha_innodb.cc; as a failsafe measure, dict_build_table_def_step() will
silently clear the compression and format flags instead of returning this
error.
dict_mem_table_create(): Assert that no extra bits are set in the flags.
dict_sys_tables_get_zip_size(): Rename to dict_sys_tables_get_flags().
Check all flag bits, and return ULINT_UNDEFINED if the combination is
unsupported.
dict_boot(): Document the SYS_TABLES columns N_COLS and TYPE.
dict_table_get_format(), dict_table_set_format(),
dict_table_flags_to_zip_size(): New accessors to table->flags.
dtuple_convert_big_rec(): Introduce the auxiliary variables
local_len, local_prefix_len. Store a 768-byte prefix locally
if the file format is less than DICT_TF_FORMAT_ZIP.
dtuple_convert_back_big_rec(): Restore the columns.
srv_file_format: New variable: innodb_file_format.
fil_create_new_single_table_tablespace(): Replace the parameter zip_size
with table->flags.
fil_open_single_table_tablespace(): Replace the parameter zip_size_in_k
with table->flags. Check the flags.
fil_space_struct, fil_space_create(), fil_op_write_log():
Replace zip_size with flags.
fil_node_open_file(): Note a TODO item for InnoDB Hot Backup.
Check that the tablespace flags match.
fil_space_get_zip_size(): Rename to fil_space_get_flags(). Add a
wrapper for fil_space_get_zip_size().
fsp_header_get_flags(): New function.
fsp_header_init_fields(): Replace zip_size with flags.
FSP_SPACE_FLAGS: New name for the tablespace flags. This field used
to be called FSP_PAGE_ZIP_SIZE, or FSP_LOWEST_NO_WRITE. It has always
been written as 0 in MySQL/InnoDB versions 4.1 to 5.1.
MLOG_ZIP_FILE_CREATE: Rename to MLOG_FILE_CREATE2. Add a 32-bit
parameter for the tablespace flags.
ha_innobase::create(): Check the table attributes ROW_FORMAT and
KEY_BLOCK_SIZE. Issue errors if they are inappropriate, or warnings
if the inherited attributes (in ALTER TABLE) will be ignored.
PAGE_ZIP_MIN_SIZE_SHIFT: New constant: the 2-logarithm of PAGE_ZIP_MIN_SIZE.
18 years ago  branches/zip: Implement the configuration parameter and settable global
variable innodb_file_format. Implement file format version stamping of
*.ibd files and SYS_TABLES.TYPE.
This change breaks introduces an incompatible change for for
compressed tables. We can do this, as we have not released yet.
innodb-zip.test: Add tests for stricter KEY_BLOCK_SIZE and ROW_FORMAT
checks.
DICT_TF_COMPRESSED_MASK, DICT_TF_COMPRESSED_SHIFT: Replace with
DICT_TF_ZSSIZE_MASK, DICT_TF_ZSSIZE_SHIFT.
DICT_TF_FORMAT_MASK, DICT_TF_FORMAT_SHIFT, DICT_TF_FORMAT_51,
DICT_TF_FORMAT_ZIP: File format version, stored in table->flags,
in the .ibd file header, and in SYS_TABLES.TYPE.
dict_create_sys_tables_tuple(): Write the table flags to SYS_TABLES.TYPE
if the format is at least DICT_TF_FORMAT_ZIP. For old formats
(DICT_TF_FORMAT_51), write DICT_TABLE_ORDINARY as the table type.
DB_TABLE_ZIP_NO_IBD: Remove the error code. The error handling is done
in ha_innodb.cc; as a failsafe measure, dict_build_table_def_step() will
silently clear the compression and format flags instead of returning this
error.
dict_mem_table_create(): Assert that no extra bits are set in the flags.
dict_sys_tables_get_zip_size(): Rename to dict_sys_tables_get_flags().
Check all flag bits, and return ULINT_UNDEFINED if the combination is
unsupported.
dict_boot(): Document the SYS_TABLES columns N_COLS and TYPE.
dict_table_get_format(), dict_table_set_format(),
dict_table_flags_to_zip_size(): New accessors to table->flags.
dtuple_convert_big_rec(): Introduce the auxiliary variables
local_len, local_prefix_len. Store a 768-byte prefix locally
if the file format is less than DICT_TF_FORMAT_ZIP.
dtuple_convert_back_big_rec(): Restore the columns.
srv_file_format: New variable: innodb_file_format.
fil_create_new_single_table_tablespace(): Replace the parameter zip_size
with table->flags.
fil_open_single_table_tablespace(): Replace the parameter zip_size_in_k
with table->flags. Check the flags.
fil_space_struct, fil_space_create(), fil_op_write_log():
Replace zip_size with flags.
fil_node_open_file(): Note a TODO item for InnoDB Hot Backup.
Check that the tablespace flags match.
fil_space_get_zip_size(): Rename to fil_space_get_flags(). Add a
wrapper for fil_space_get_zip_size().
fsp_header_get_flags(): New function.
fsp_header_init_fields(): Replace zip_size with flags.
FSP_SPACE_FLAGS: New name for the tablespace flags. This field used
to be called FSP_PAGE_ZIP_SIZE, or FSP_LOWEST_NO_WRITE. It has always
been written as 0 in MySQL/InnoDB versions 4.1 to 5.1.
MLOG_ZIP_FILE_CREATE: Rename to MLOG_FILE_CREATE2. Add a 32-bit
parameter for the tablespace flags.
ha_innobase::create(): Check the table attributes ROW_FORMAT and
KEY_BLOCK_SIZE. Issue errors if they are inappropriate, or warnings
if the inherited attributes (in ALTER TABLE) will be ignored.
PAGE_ZIP_MIN_SIZE_SHIFT: New constant: the 2-logarithm of PAGE_ZIP_MIN_SIZE.
18 years ago  branches/zip: Implement the configuration parameter and settable global
variable innodb_file_format. Implement file format version stamping of
*.ibd files and SYS_TABLES.TYPE.
This change breaks introduces an incompatible change for for
compressed tables. We can do this, as we have not released yet.
innodb-zip.test: Add tests for stricter KEY_BLOCK_SIZE and ROW_FORMAT
checks.
DICT_TF_COMPRESSED_MASK, DICT_TF_COMPRESSED_SHIFT: Replace with
DICT_TF_ZSSIZE_MASK, DICT_TF_ZSSIZE_SHIFT.
DICT_TF_FORMAT_MASK, DICT_TF_FORMAT_SHIFT, DICT_TF_FORMAT_51,
DICT_TF_FORMAT_ZIP: File format version, stored in table->flags,
in the .ibd file header, and in SYS_TABLES.TYPE.
dict_create_sys_tables_tuple(): Write the table flags to SYS_TABLES.TYPE
if the format is at least DICT_TF_FORMAT_ZIP. For old formats
(DICT_TF_FORMAT_51), write DICT_TABLE_ORDINARY as the table type.
DB_TABLE_ZIP_NO_IBD: Remove the error code. The error handling is done
in ha_innodb.cc; as a failsafe measure, dict_build_table_def_step() will
silently clear the compression and format flags instead of returning this
error.
dict_mem_table_create(): Assert that no extra bits are set in the flags.
dict_sys_tables_get_zip_size(): Rename to dict_sys_tables_get_flags().
Check all flag bits, and return ULINT_UNDEFINED if the combination is
unsupported.
dict_boot(): Document the SYS_TABLES columns N_COLS and TYPE.
dict_table_get_format(), dict_table_set_format(),
dict_table_flags_to_zip_size(): New accessors to table->flags.
dtuple_convert_big_rec(): Introduce the auxiliary variables
local_len, local_prefix_len. Store a 768-byte prefix locally
if the file format is less than DICT_TF_FORMAT_ZIP.
dtuple_convert_back_big_rec(): Restore the columns.
srv_file_format: New variable: innodb_file_format.
fil_create_new_single_table_tablespace(): Replace the parameter zip_size
with table->flags.
fil_open_single_table_tablespace(): Replace the parameter zip_size_in_k
with table->flags. Check the flags.
fil_space_struct, fil_space_create(), fil_op_write_log():
Replace zip_size with flags.
fil_node_open_file(): Note a TODO item for InnoDB Hot Backup.
Check that the tablespace flags match.
fil_space_get_zip_size(): Rename to fil_space_get_flags(). Add a
wrapper for fil_space_get_zip_size().
fsp_header_get_flags(): New function.
fsp_header_init_fields(): Replace zip_size with flags.
FSP_SPACE_FLAGS: New name for the tablespace flags. This field used
to be called FSP_PAGE_ZIP_SIZE, or FSP_LOWEST_NO_WRITE. It has always
been written as 0 in MySQL/InnoDB versions 4.1 to 5.1.
MLOG_ZIP_FILE_CREATE: Rename to MLOG_FILE_CREATE2. Add a 32-bit
parameter for the tablespace flags.
ha_innobase::create(): Check the table attributes ROW_FORMAT and
KEY_BLOCK_SIZE. Issue errors if they are inappropriate, or warnings
if the inherited attributes (in ALTER TABLE) will be ignored.
PAGE_ZIP_MIN_SIZE_SHIFT: New constant: the 2-logarithm of PAGE_ZIP_MIN_SIZE.
18 years ago  branches/zip:
Merge 2929:3458 from branches/5.1 (resolving conflict in c3257,
note also that r3363 reverted r2933 so there are not changes in
mysql-test/innodb-autoinc.result with the current merge):
------------------------------------------------------------------------
r2933 | calvin | 2008-10-30 02:57:31 +0200 (Thu, 30 Oct 2008) | 10 lines
Changed paths:
M /branches/5.1/mysql-test/innodb-autoinc.result
branches/5.1: correct the result file innodb-autoinc.result
Change the followings:
auto_increment_increment
auto_increment_offset
to
auto-increment-increment
auto-increment-offset
------------------------------------------------------------------------
r2981 | marko | 2008-11-07 14:54:10 +0200 (Fri, 07 Nov 2008) | 5 lines
Changed paths:
M /branches/5.1/row/row0mysql.c
branches/5.0: row_mysql_store_col_in_innobase_format(): Correct a misleading
comment. In the UTF-8 encoding, ASCII takes 1 byte per character, while
the "latin1" character set (normally ISO-8859-1, but in MySQL it actually
refers to the Windows Code Page 1252 a.k.a. CP1252, WinLatin1)
takes 1 to 3 bytes (1 to 2 bytes for the ISO-8859-1 subset).
------------------------------------------------------------------------
r3114 | calvin | 2008-11-14 20:31:48 +0200 (Fri, 14 Nov 2008) | 8 lines
Changed paths:
M /branches/5.1/handler/ha_innodb.cc
branches/5.1: fix bug#40386: Not flushing query cache after truncate
ha_statistics.records can not be 0 unless the table is empty, set to
1 instead. The original problem of bug#29507 is fixed in the server.
Additional test was done with the fix of bug#29507 in the server.
Approved by: Heikki (on IM)
------------------------------------------------------------------------
r3257 | inaam | 2008-11-24 22:06:50 +0200 (Mon, 24 Nov 2008) | 13 lines
Changed paths:
M /branches/5.1/handler/ha_innodb.cc
M /branches/5.1/srv/srv0srv.c
M /branches/5.1/trx/trx0trx.c
branches/5.1 bug#40760
The config param innodb_thread_concurrency is dynamically set and is
read when a thread enters/exits innodb. If the value is changed between
the enter and exit time the behaviour becomes erratic.
The fix is not to use srv_thread_concurrency when exiting, instead use
the flag trx->declared_to_be_inside_innodb.
rb://57
Approved by: Marko
------------------------------------------------------------------------
r3363 | calvin | 2008-12-04 19:00:20 +0200 (Thu, 04 Dec 2008) | 13 lines
Changed paths:
M /branches/5.1/mysql-test/innodb-autoinc.result
branches/5.1: revert the changes in r2933
The changes in r2933 causes test failure on Linux.
More investigation is needed for Windows.
Change the followings in innodb-autoinc.result:
auto-increment-increment
auto-increment-offset
back to:
auto_increment_increment
auto_increment_offset
------------------------------------------------------------------------
r3412 | vasil | 2008-12-05 10:46:18 +0200 (Fri, 05 Dec 2008) | 7 lines
Changed paths:
M /branches/5.1/trx/trx0undo.c
branches/5.1:
Add the traditional 2 spaces after the timestamp so the message does
not look like:
070223 13:26:01InnoDB: Warning: canno....
------------------------------------------------------------------------
r3458 | vasil | 2008-12-09 11:21:08 +0200 (Tue, 09 Dec 2008) | 51 lines
Changed paths:
M /branches/5.1/mysql-test/innodb_bug34300.test
branches/5.1:
Merge a change from MySQL to fix the failing innodb_bug34300 mysql-test:
main.innodb_bug34300 [ fail ]
mysqltest: At line 11: query 'SET @@max_allowed_packet=16777216' failed: 1621: SESSION variable 'max_allowed_packet' is read-only. Use SET GLOBAL to assign the value
Aborting: main.innodb_bug34300 failed in default mode.
The changeset is this:
------------------------------------------------------------
revno: 2709.1.10
committer: Staale Smedseng <staale.smedseng@sun.com>
branch nick: b22891-51-bugteam
timestamp: Thu 2008-11-20 08:51:48 +0100
message:
A fix for Bug#22891 "session level max_allowed_packet can be
set but is ignored".
This patch makes @@session.max_allowed_packed and
@@session.net_buffer_length read-only as suggested in the bug
report. The user will have to use SET GLOBAL (and reconnect)
to alter the session values of these variables.
The error string ER_VARIABLE_IS_READONLY is introduced.
Tests are modified accordingly.
modified:
mysql-test/r/func_compress.result
mysql-test/r/max_allowed_packet_basic.result
mysql-test/r/max_allowed_packet_func.result
mysql-test/r/net_buffer_length_basic.result
mysql-test/r/packet.result
mysql-test/r/union.result
mysql-test/r/variables.result
mysql-test/t/func_compress.test
mysql-test/t/innodb_bug34300.test
mysql-test/t/max_allowed_packet_basic.test
mysql-test/t/max_allowed_packet_func.test
mysql-test/t/net_buffer_length_basic.test
mysql-test/t/packet.test
mysql-test/t/union.test
mysql-test/t/variables.test
sql/set_var.cc
sql/set_var.h
sql/share/errmsg.txt
------------------------------------------------------------
------------------------------------------------------------------------
17 years ago branches/zip: Remove some unnecessary memory references in the master thread.
srv_print_thread_releases, srv_print_lock_waits, srv_print_buf_io,
srv_print_log_io, srv_print_latch_waits: Define these variables as
constants (FALSE), unless UNIV_DEBUG is defined. These variables
are never assigned to, and they are initialized to FALSE. It could
be useful to set them when debugging InnoDB.
srv_slot_t: Fuse the fields type, in_use, suspended to a single machine word.
srv_meter[], srv_meter_low_water[], srv_meter_high_water[],
srv_meter_high_water2[], srv_meter_foreground[]: Enclose these arrays
inside #if 0. The arrays are essentially constants that do not affect
the control flow.
enum srv_thread_type: New enum, to replace the #defines SRV_COM, ...
Enclose the unused values SRV_BUFFER, SRV_RECOVERY, SRV_INSERT
inside #if 0, so that some arrays and loops can be reduced.
18 years ago branches/zip: Remove some unnecessary memory references in the master thread.
srv_print_thread_releases, srv_print_lock_waits, srv_print_buf_io,
srv_print_log_io, srv_print_latch_waits: Define these variables as
constants (FALSE), unless UNIV_DEBUG is defined. These variables
are never assigned to, and they are initialized to FALSE. It could
be useful to set them when debugging InnoDB.
srv_slot_t: Fuse the fields type, in_use, suspended to a single machine word.
srv_meter[], srv_meter_low_water[], srv_meter_high_water[],
srv_meter_high_water2[], srv_meter_foreground[]: Enclose these arrays
inside #if 0. The arrays are essentially constants that do not affect
the control flow.
enum srv_thread_type: New enum, to replace the #defines SRV_COM, ...
Enclose the unused values SRV_BUFFER, SRV_RECOVERY, SRV_INSERT
inside #if 0, so that some arrays and loops can be reduced.
18 years ago branches/zip: Remove some unnecessary memory references in the master thread.
srv_print_thread_releases, srv_print_lock_waits, srv_print_buf_io,
srv_print_log_io, srv_print_latch_waits: Define these variables as
constants (FALSE), unless UNIV_DEBUG is defined. These variables
are never assigned to, and they are initialized to FALSE. It could
be useful to set them when debugging InnoDB.
srv_slot_t: Fuse the fields type, in_use, suspended to a single machine word.
srv_meter[], srv_meter_low_water[], srv_meter_high_water[],
srv_meter_high_water2[], srv_meter_foreground[]: Enclose these arrays
inside #if 0. The arrays are essentially constants that do not affect
the control flow.
enum srv_thread_type: New enum, to replace the #defines SRV_COM, ...
Enclose the unused values SRV_BUFFER, SRV_RECOVERY, SRV_INSERT
inside #if 0, so that some arrays and loops can be reduced.
18 years ago branches/zip: Remove some unnecessary memory references in the master thread.
srv_print_thread_releases, srv_print_lock_waits, srv_print_buf_io,
srv_print_log_io, srv_print_latch_waits: Define these variables as
constants (FALSE), unless UNIV_DEBUG is defined. These variables
are never assigned to, and they are initialized to FALSE. It could
be useful to set them when debugging InnoDB.
srv_slot_t: Fuse the fields type, in_use, suspended to a single machine word.
srv_meter[], srv_meter_low_water[], srv_meter_high_water[],
srv_meter_high_water2[], srv_meter_foreground[]: Enclose these arrays
inside #if 0. The arrays are essentially constants that do not affect
the control flow.
enum srv_thread_type: New enum, to replace the #defines SRV_COM, ...
Enclose the unused values SRV_BUFFER, SRV_RECOVERY, SRV_INSERT
inside #if 0, so that some arrays and loops can be reduced.
18 years ago branches/zip: Remove some unnecessary memory references in the master thread.
srv_print_thread_releases, srv_print_lock_waits, srv_print_buf_io,
srv_print_log_io, srv_print_latch_waits: Define these variables as
constants (FALSE), unless UNIV_DEBUG is defined. These variables
are never assigned to, and they are initialized to FALSE. It could
be useful to set them when debugging InnoDB.
srv_slot_t: Fuse the fields type, in_use, suspended to a single machine word.
srv_meter[], srv_meter_low_water[], srv_meter_high_water[],
srv_meter_high_water2[], srv_meter_foreground[]: Enclose these arrays
inside #if 0. The arrays are essentially constants that do not affect
the control flow.
enum srv_thread_type: New enum, to replace the #defines SRV_COM, ...
Enclose the unused values SRV_BUFFER, SRV_RECOVERY, SRV_INSERT
inside #if 0, so that some arrays and loops can be reduced.
18 years ago branches/zip: Remove some unnecessary memory references in the master thread.
srv_print_thread_releases, srv_print_lock_waits, srv_print_buf_io,
srv_print_log_io, srv_print_latch_waits: Define these variables as
constants (FALSE), unless UNIV_DEBUG is defined. These variables
are never assigned to, and they are initialized to FALSE. It could
be useful to set them when debugging InnoDB.
srv_slot_t: Fuse the fields type, in_use, suspended to a single machine word.
srv_meter[], srv_meter_low_water[], srv_meter_high_water[],
srv_meter_high_water2[], srv_meter_foreground[]: Enclose these arrays
inside #if 0. The arrays are essentially constants that do not affect
the control flow.
enum srv_thread_type: New enum, to replace the #defines SRV_COM, ...
Enclose the unused values SRV_BUFFER, SRV_RECOVERY, SRV_INSERT
inside #if 0, so that some arrays and loops can be reduced.
18 years ago branches/zip: Remove some unnecessary memory references in the master thread.
srv_print_thread_releases, srv_print_lock_waits, srv_print_buf_io,
srv_print_log_io, srv_print_latch_waits: Define these variables as
constants (FALSE), unless UNIV_DEBUG is defined. These variables
are never assigned to, and they are initialized to FALSE. It could
be useful to set them when debugging InnoDB.
srv_slot_t: Fuse the fields type, in_use, suspended to a single machine word.
srv_meter[], srv_meter_low_water[], srv_meter_high_water[],
srv_meter_high_water2[], srv_meter_foreground[]: Enclose these arrays
inside #if 0. The arrays are essentially constants that do not affect
the control flow.
enum srv_thread_type: New enum, to replace the #defines SRV_COM, ...
Enclose the unused values SRV_BUFFER, SRV_RECOVERY, SRV_INSERT
inside #if 0, so that some arrays and loops can be reduced.
18 years ago branches/zip: Remove some unnecessary memory references in the master thread.
srv_print_thread_releases, srv_print_lock_waits, srv_print_buf_io,
srv_print_log_io, srv_print_latch_waits: Define these variables as
constants (FALSE), unless UNIV_DEBUG is defined. These variables
are never assigned to, and they are initialized to FALSE. It could
be useful to set them when debugging InnoDB.
srv_slot_t: Fuse the fields type, in_use, suspended to a single machine word.
srv_meter[], srv_meter_low_water[], srv_meter_high_water[],
srv_meter_high_water2[], srv_meter_foreground[]: Enclose these arrays
inside #if 0. The arrays are essentially constants that do not affect
the control flow.
enum srv_thread_type: New enum, to replace the #defines SRV_COM, ...
Enclose the unused values SRV_BUFFER, SRV_RECOVERY, SRV_INSERT
inside #if 0, so that some arrays and loops can be reduced.
18 years ago branches/zip: Remove some unnecessary memory references in the master thread.
srv_print_thread_releases, srv_print_lock_waits, srv_print_buf_io,
srv_print_log_io, srv_print_latch_waits: Define these variables as
constants (FALSE), unless UNIV_DEBUG is defined. These variables
are never assigned to, and they are initialized to FALSE. It could
be useful to set them when debugging InnoDB.
srv_slot_t: Fuse the fields type, in_use, suspended to a single machine word.
srv_meter[], srv_meter_low_water[], srv_meter_high_water[],
srv_meter_high_water2[], srv_meter_foreground[]: Enclose these arrays
inside #if 0. The arrays are essentially constants that do not affect
the control flow.
enum srv_thread_type: New enum, to replace the #defines SRV_COM, ...
Enclose the unused values SRV_BUFFER, SRV_RECOVERY, SRV_INSERT
inside #if 0, so that some arrays and loops can be reduced.
18 years ago branches/zip: Remove some unnecessary memory references in the master thread.
srv_print_thread_releases, srv_print_lock_waits, srv_print_buf_io,
srv_print_log_io, srv_print_latch_waits: Define these variables as
constants (FALSE), unless UNIV_DEBUG is defined. These variables
are never assigned to, and they are initialized to FALSE. It could
be useful to set them when debugging InnoDB.
srv_slot_t: Fuse the fields type, in_use, suspended to a single machine word.
srv_meter[], srv_meter_low_water[], srv_meter_high_water[],
srv_meter_high_water2[], srv_meter_foreground[]: Enclose these arrays
inside #if 0. The arrays are essentially constants that do not affect
the control flow.
enum srv_thread_type: New enum, to replace the #defines SRV_COM, ...
Enclose the unused values SRV_BUFFER, SRV_RECOVERY, SRV_INSERT
inside #if 0, so that some arrays and loops can be reduced.
18 years ago branches/zip: Remove some unnecessary memory references in the master thread.
srv_print_thread_releases, srv_print_lock_waits, srv_print_buf_io,
srv_print_log_io, srv_print_latch_waits: Define these variables as
constants (FALSE), unless UNIV_DEBUG is defined. These variables
are never assigned to, and they are initialized to FALSE. It could
be useful to set them when debugging InnoDB.
srv_slot_t: Fuse the fields type, in_use, suspended to a single machine word.
srv_meter[], srv_meter_low_water[], srv_meter_high_water[],
srv_meter_high_water2[], srv_meter_foreground[]: Enclose these arrays
inside #if 0. The arrays are essentially constants that do not affect
the control flow.
enum srv_thread_type: New enum, to replace the #defines SRV_COM, ...
Enclose the unused values SRV_BUFFER, SRV_RECOVERY, SRV_INSERT
inside #if 0, so that some arrays and loops can be reduced.
18 years ago branches/zip: Remove some unnecessary memory references in the master thread.
srv_print_thread_releases, srv_print_lock_waits, srv_print_buf_io,
srv_print_log_io, srv_print_latch_waits: Define these variables as
constants (FALSE), unless UNIV_DEBUG is defined. These variables
are never assigned to, and they are initialized to FALSE. It could
be useful to set them when debugging InnoDB.
srv_slot_t: Fuse the fields type, in_use, suspended to a single machine word.
srv_meter[], srv_meter_low_water[], srv_meter_high_water[],
srv_meter_high_water2[], srv_meter_foreground[]: Enclose these arrays
inside #if 0. The arrays are essentially constants that do not affect
the control flow.
enum srv_thread_type: New enum, to replace the #defines SRV_COM, ...
Enclose the unused values SRV_BUFFER, SRV_RECOVERY, SRV_INSERT
inside #if 0, so that some arrays and loops can be reduced.
18 years ago branches/zip: Remove some unnecessary memory references in the master thread.
srv_print_thread_releases, srv_print_lock_waits, srv_print_buf_io,
srv_print_log_io, srv_print_latch_waits: Define these variables as
constants (FALSE), unless UNIV_DEBUG is defined. These variables
are never assigned to, and they are initialized to FALSE. It could
be useful to set them when debugging InnoDB.
srv_slot_t: Fuse the fields type, in_use, suspended to a single machine word.
srv_meter[], srv_meter_low_water[], srv_meter_high_water[],
srv_meter_high_water2[], srv_meter_foreground[]: Enclose these arrays
inside #if 0. The arrays are essentially constants that do not affect
the control flow.
enum srv_thread_type: New enum, to replace the #defines SRV_COM, ...
Enclose the unused values SRV_BUFFER, SRV_RECOVERY, SRV_INSERT
inside #if 0, so that some arrays and loops can be reduced.
18 years ago branches/zip: Remove some unnecessary memory references in the master thread.
srv_print_thread_releases, srv_print_lock_waits, srv_print_buf_io,
srv_print_log_io, srv_print_latch_waits: Define these variables as
constants (FALSE), unless UNIV_DEBUG is defined. These variables
are never assigned to, and they are initialized to FALSE. It could
be useful to set them when debugging InnoDB.
srv_slot_t: Fuse the fields type, in_use, suspended to a single machine word.
srv_meter[], srv_meter_low_water[], srv_meter_high_water[],
srv_meter_high_water2[], srv_meter_foreground[]: Enclose these arrays
inside #if 0. The arrays are essentially constants that do not affect
the control flow.
enum srv_thread_type: New enum, to replace the #defines SRV_COM, ...
Enclose the unused values SRV_BUFFER, SRV_RECOVERY, SRV_INSERT
inside #if 0, so that some arrays and loops can be reduced.
18 years ago branches/zip: Remove some unnecessary memory references in the master thread.
srv_print_thread_releases, srv_print_lock_waits, srv_print_buf_io,
srv_print_log_io, srv_print_latch_waits: Define these variables as
constants (FALSE), unless UNIV_DEBUG is defined. These variables
are never assigned to, and they are initialized to FALSE. It could
be useful to set them when debugging InnoDB.
srv_slot_t: Fuse the fields type, in_use, suspended to a single machine word.
srv_meter[], srv_meter_low_water[], srv_meter_high_water[],
srv_meter_high_water2[], srv_meter_foreground[]: Enclose these arrays
inside #if 0. The arrays are essentially constants that do not affect
the control flow.
enum srv_thread_type: New enum, to replace the #defines SRV_COM, ...
Enclose the unused values SRV_BUFFER, SRV_RECOVERY, SRV_INSERT
inside #if 0, so that some arrays and loops can be reduced.
18 years ago branches/zip: Remove some unnecessary memory references in the master thread.
srv_print_thread_releases, srv_print_lock_waits, srv_print_buf_io,
srv_print_log_io, srv_print_latch_waits: Define these variables as
constants (FALSE), unless UNIV_DEBUG is defined. These variables
are never assigned to, and they are initialized to FALSE. It could
be useful to set them when debugging InnoDB.
srv_slot_t: Fuse the fields type, in_use, suspended to a single machine word.
srv_meter[], srv_meter_low_water[], srv_meter_high_water[],
srv_meter_high_water2[], srv_meter_foreground[]: Enclose these arrays
inside #if 0. The arrays are essentially constants that do not affect
the control flow.
enum srv_thread_type: New enum, to replace the #defines SRV_COM, ...
Enclose the unused values SRV_BUFFER, SRV_RECOVERY, SRV_INSERT
inside #if 0, so that some arrays and loops can be reduced.
18 years ago  branches/zip:
Merge 2929:3458 from branches/5.1 (resolving conflict in c3257,
note also that r3363 reverted r2933 so there are not changes in
mysql-test/innodb-autoinc.result with the current merge):
------------------------------------------------------------------------
r2933 | calvin | 2008-10-30 02:57:31 +0200 (Thu, 30 Oct 2008) | 10 lines
Changed paths:
M /branches/5.1/mysql-test/innodb-autoinc.result
branches/5.1: correct the result file innodb-autoinc.result
Change the followings:
auto_increment_increment
auto_increment_offset
to
auto-increment-increment
auto-increment-offset
------------------------------------------------------------------------
r2981 | marko | 2008-11-07 14:54:10 +0200 (Fri, 07 Nov 2008) | 5 lines
Changed paths:
M /branches/5.1/row/row0mysql.c
branches/5.0: row_mysql_store_col_in_innobase_format(): Correct a misleading
comment. In the UTF-8 encoding, ASCII takes 1 byte per character, while
the "latin1" character set (normally ISO-8859-1, but in MySQL it actually
refers to the Windows Code Page 1252 a.k.a. CP1252, WinLatin1)
takes 1 to 3 bytes (1 to 2 bytes for the ISO-8859-1 subset).
------------------------------------------------------------------------
r3114 | calvin | 2008-11-14 20:31:48 +0200 (Fri, 14 Nov 2008) | 8 lines
Changed paths:
M /branches/5.1/handler/ha_innodb.cc
branches/5.1: fix bug#40386: Not flushing query cache after truncate
ha_statistics.records can not be 0 unless the table is empty, set to
1 instead. The original problem of bug#29507 is fixed in the server.
Additional test was done with the fix of bug#29507 in the server.
Approved by: Heikki (on IM)
------------------------------------------------------------------------
r3257 | inaam | 2008-11-24 22:06:50 +0200 (Mon, 24 Nov 2008) | 13 lines
Changed paths:
M /branches/5.1/handler/ha_innodb.cc
M /branches/5.1/srv/srv0srv.c
M /branches/5.1/trx/trx0trx.c
branches/5.1 bug#40760
The config param innodb_thread_concurrency is dynamically set and is
read when a thread enters/exits innodb. If the value is changed between
the enter and exit time the behaviour becomes erratic.
The fix is not to use srv_thread_concurrency when exiting, instead use
the flag trx->declared_to_be_inside_innodb.
rb://57
Approved by: Marko
------------------------------------------------------------------------
r3363 | calvin | 2008-12-04 19:00:20 +0200 (Thu, 04 Dec 2008) | 13 lines
Changed paths:
M /branches/5.1/mysql-test/innodb-autoinc.result
branches/5.1: revert the changes in r2933
The changes in r2933 causes test failure on Linux.
More investigation is needed for Windows.
Change the followings in innodb-autoinc.result:
auto-increment-increment
auto-increment-offset
back to:
auto_increment_increment
auto_increment_offset
------------------------------------------------------------------------
r3412 | vasil | 2008-12-05 10:46:18 +0200 (Fri, 05 Dec 2008) | 7 lines
Changed paths:
M /branches/5.1/trx/trx0undo.c
branches/5.1:
Add the traditional 2 spaces after the timestamp so the message does
not look like:
070223 13:26:01InnoDB: Warning: canno....
------------------------------------------------------------------------
r3458 | vasil | 2008-12-09 11:21:08 +0200 (Tue, 09 Dec 2008) | 51 lines
Changed paths:
M /branches/5.1/mysql-test/innodb_bug34300.test
branches/5.1:
Merge a change from MySQL to fix the failing innodb_bug34300 mysql-test:
main.innodb_bug34300 [ fail ]
mysqltest: At line 11: query 'SET @@max_allowed_packet=16777216' failed: 1621: SESSION variable 'max_allowed_packet' is read-only. Use SET GLOBAL to assign the value
Aborting: main.innodb_bug34300 failed in default mode.
The changeset is this:
------------------------------------------------------------
revno: 2709.1.10
committer: Staale Smedseng <staale.smedseng@sun.com>
branch nick: b22891-51-bugteam
timestamp: Thu 2008-11-20 08:51:48 +0100
message:
A fix for Bug#22891 "session level max_allowed_packet can be
set but is ignored".
This patch makes @@session.max_allowed_packed and
@@session.net_buffer_length read-only as suggested in the bug
report. The user will have to use SET GLOBAL (and reconnect)
to alter the session values of these variables.
The error string ER_VARIABLE_IS_READONLY is introduced.
Tests are modified accordingly.
modified:
mysql-test/r/func_compress.result
mysql-test/r/max_allowed_packet_basic.result
mysql-test/r/max_allowed_packet_func.result
mysql-test/r/net_buffer_length_basic.result
mysql-test/r/packet.result
mysql-test/r/union.result
mysql-test/r/variables.result
mysql-test/t/func_compress.test
mysql-test/t/innodb_bug34300.test
mysql-test/t/max_allowed_packet_basic.test
mysql-test/t/max_allowed_packet_func.test
mysql-test/t/net_buffer_length_basic.test
mysql-test/t/packet.test
mysql-test/t/union.test
mysql-test/t/variables.test
sql/set_var.cc
sql/set_var.h
sql/share/errmsg.txt
------------------------------------------------------------
------------------------------------------------------------------------
17 years ago  branches/zip:
Merge 2929:3458 from branches/5.1 (resolving conflict in c3257,
note also that r3363 reverted r2933 so there are not changes in
mysql-test/innodb-autoinc.result with the current merge):
------------------------------------------------------------------------
r2933 | calvin | 2008-10-30 02:57:31 +0200 (Thu, 30 Oct 2008) | 10 lines
Changed paths:
M /branches/5.1/mysql-test/innodb-autoinc.result
branches/5.1: correct the result file innodb-autoinc.result
Change the followings:
auto_increment_increment
auto_increment_offset
to
auto-increment-increment
auto-increment-offset
------------------------------------------------------------------------
r2981 | marko | 2008-11-07 14:54:10 +0200 (Fri, 07 Nov 2008) | 5 lines
Changed paths:
M /branches/5.1/row/row0mysql.c
branches/5.0: row_mysql_store_col_in_innobase_format(): Correct a misleading
comment. In the UTF-8 encoding, ASCII takes 1 byte per character, while
the "latin1" character set (normally ISO-8859-1, but in MySQL it actually
refers to the Windows Code Page 1252 a.k.a. CP1252, WinLatin1)
takes 1 to 3 bytes (1 to 2 bytes for the ISO-8859-1 subset).
------------------------------------------------------------------------
r3114 | calvin | 2008-11-14 20:31:48 +0200 (Fri, 14 Nov 2008) | 8 lines
Changed paths:
M /branches/5.1/handler/ha_innodb.cc
branches/5.1: fix bug#40386: Not flushing query cache after truncate
ha_statistics.records can not be 0 unless the table is empty, set to
1 instead. The original problem of bug#29507 is fixed in the server.
Additional test was done with the fix of bug#29507 in the server.
Approved by: Heikki (on IM)
------------------------------------------------------------------------
r3257 | inaam | 2008-11-24 22:06:50 +0200 (Mon, 24 Nov 2008) | 13 lines
Changed paths:
M /branches/5.1/handler/ha_innodb.cc
M /branches/5.1/srv/srv0srv.c
M /branches/5.1/trx/trx0trx.c
branches/5.1 bug#40760
The config param innodb_thread_concurrency is dynamically set and is
read when a thread enters/exits innodb. If the value is changed between
the enter and exit time the behaviour becomes erratic.
The fix is not to use srv_thread_concurrency when exiting, instead use
the flag trx->declared_to_be_inside_innodb.
rb://57
Approved by: Marko
------------------------------------------------------------------------
r3363 | calvin | 2008-12-04 19:00:20 +0200 (Thu, 04 Dec 2008) | 13 lines
Changed paths:
M /branches/5.1/mysql-test/innodb-autoinc.result
branches/5.1: revert the changes in r2933
The changes in r2933 causes test failure on Linux.
More investigation is needed for Windows.
Change the followings in innodb-autoinc.result:
auto-increment-increment
auto-increment-offset
back to:
auto_increment_increment
auto_increment_offset
------------------------------------------------------------------------
r3412 | vasil | 2008-12-05 10:46:18 +0200 (Fri, 05 Dec 2008) | 7 lines
Changed paths:
M /branches/5.1/trx/trx0undo.c
branches/5.1:
Add the traditional 2 spaces after the timestamp so the message does
not look like:
070223 13:26:01InnoDB: Warning: canno....
------------------------------------------------------------------------
r3458 | vasil | 2008-12-09 11:21:08 +0200 (Tue, 09 Dec 2008) | 51 lines
Changed paths:
M /branches/5.1/mysql-test/innodb_bug34300.test
branches/5.1:
Merge a change from MySQL to fix the failing innodb_bug34300 mysql-test:
main.innodb_bug34300 [ fail ]
mysqltest: At line 11: query 'SET @@max_allowed_packet=16777216' failed: 1621: SESSION variable 'max_allowed_packet' is read-only. Use SET GLOBAL to assign the value
Aborting: main.innodb_bug34300 failed in default mode.
The changeset is this:
------------------------------------------------------------
revno: 2709.1.10
committer: Staale Smedseng <staale.smedseng@sun.com>
branch nick: b22891-51-bugteam
timestamp: Thu 2008-11-20 08:51:48 +0100
message:
A fix for Bug#22891 "session level max_allowed_packet can be
set but is ignored".
This patch makes @@session.max_allowed_packed and
@@session.net_buffer_length read-only as suggested in the bug
report. The user will have to use SET GLOBAL (and reconnect)
to alter the session values of these variables.
The error string ER_VARIABLE_IS_READONLY is introduced.
Tests are modified accordingly.
modified:
mysql-test/r/func_compress.result
mysql-test/r/max_allowed_packet_basic.result
mysql-test/r/max_allowed_packet_func.result
mysql-test/r/net_buffer_length_basic.result
mysql-test/r/packet.result
mysql-test/r/union.result
mysql-test/r/variables.result
mysql-test/t/func_compress.test
mysql-test/t/innodb_bug34300.test
mysql-test/t/max_allowed_packet_basic.test
mysql-test/t/max_allowed_packet_func.test
mysql-test/t/net_buffer_length_basic.test
mysql-test/t/packet.test
mysql-test/t/union.test
mysql-test/t/variables.test
sql/set_var.cc
sql/set_var.h
sql/share/errmsg.txt
------------------------------------------------------------
------------------------------------------------------------------------
17 years ago  branches/zip:
Merge 2929:3458 from branches/5.1 (resolving conflict in c3257,
note also that r3363 reverted r2933 so there are not changes in
mysql-test/innodb-autoinc.result with the current merge):
------------------------------------------------------------------------
r2933 | calvin | 2008-10-30 02:57:31 +0200 (Thu, 30 Oct 2008) | 10 lines
Changed paths:
M /branches/5.1/mysql-test/innodb-autoinc.result
branches/5.1: correct the result file innodb-autoinc.result
Change the followings:
auto_increment_increment
auto_increment_offset
to
auto-increment-increment
auto-increment-offset
------------------------------------------------------------------------
r2981 | marko | 2008-11-07 14:54:10 +0200 (Fri, 07 Nov 2008) | 5 lines
Changed paths:
M /branches/5.1/row/row0mysql.c
branches/5.0: row_mysql_store_col_in_innobase_format(): Correct a misleading
comment. In the UTF-8 encoding, ASCII takes 1 byte per character, while
the "latin1" character set (normally ISO-8859-1, but in MySQL it actually
refers to the Windows Code Page 1252 a.k.a. CP1252, WinLatin1)
takes 1 to 3 bytes (1 to 2 bytes for the ISO-8859-1 subset).
------------------------------------------------------------------------
r3114 | calvin | 2008-11-14 20:31:48 +0200 (Fri, 14 Nov 2008) | 8 lines
Changed paths:
M /branches/5.1/handler/ha_innodb.cc
branches/5.1: fix bug#40386: Not flushing query cache after truncate
ha_statistics.records can not be 0 unless the table is empty, set to
1 instead. The original problem of bug#29507 is fixed in the server.
Additional test was done with the fix of bug#29507 in the server.
Approved by: Heikki (on IM)
------------------------------------------------------------------------
r3257 | inaam | 2008-11-24 22:06:50 +0200 (Mon, 24 Nov 2008) | 13 lines
Changed paths:
M /branches/5.1/handler/ha_innodb.cc
M /branches/5.1/srv/srv0srv.c
M /branches/5.1/trx/trx0trx.c
branches/5.1 bug#40760
The config param innodb_thread_concurrency is dynamically set and is
read when a thread enters/exits innodb. If the value is changed between
the enter and exit time the behaviour becomes erratic.
The fix is not to use srv_thread_concurrency when exiting, instead use
the flag trx->declared_to_be_inside_innodb.
rb://57
Approved by: Marko
------------------------------------------------------------------------
r3363 | calvin | 2008-12-04 19:00:20 +0200 (Thu, 04 Dec 2008) | 13 lines
Changed paths:
M /branches/5.1/mysql-test/innodb-autoinc.result
branches/5.1: revert the changes in r2933
The changes in r2933 causes test failure on Linux.
More investigation is needed for Windows.
Change the followings in innodb-autoinc.result:
auto-increment-increment
auto-increment-offset
back to:
auto_increment_increment
auto_increment_offset
------------------------------------------------------------------------
r3412 | vasil | 2008-12-05 10:46:18 +0200 (Fri, 05 Dec 2008) | 7 lines
Changed paths:
M /branches/5.1/trx/trx0undo.c
branches/5.1:
Add the traditional 2 spaces after the timestamp so the message does
not look like:
070223 13:26:01InnoDB: Warning: canno....
------------------------------------------------------------------------
r3458 | vasil | 2008-12-09 11:21:08 +0200 (Tue, 09 Dec 2008) | 51 lines
Changed paths:
M /branches/5.1/mysql-test/innodb_bug34300.test
branches/5.1:
Merge a change from MySQL to fix the failing innodb_bug34300 mysql-test:
main.innodb_bug34300 [ fail ]
mysqltest: At line 11: query 'SET @@max_allowed_packet=16777216' failed: 1621: SESSION variable 'max_allowed_packet' is read-only. Use SET GLOBAL to assign the value
Aborting: main.innodb_bug34300 failed in default mode.
The changeset is this:
------------------------------------------------------------
revno: 2709.1.10
committer: Staale Smedseng <staale.smedseng@sun.com>
branch nick: b22891-51-bugteam
timestamp: Thu 2008-11-20 08:51:48 +0100
message:
A fix for Bug#22891 "session level max_allowed_packet can be
set but is ignored".
This patch makes @@session.max_allowed_packed and
@@session.net_buffer_length read-only as suggested in the bug
report. The user will have to use SET GLOBAL (and reconnect)
to alter the session values of these variables.
The error string ER_VARIABLE_IS_READONLY is introduced.
Tests are modified accordingly.
modified:
mysql-test/r/func_compress.result
mysql-test/r/max_allowed_packet_basic.result
mysql-test/r/max_allowed_packet_func.result
mysql-test/r/net_buffer_length_basic.result
mysql-test/r/packet.result
mysql-test/r/union.result
mysql-test/r/variables.result
mysql-test/t/func_compress.test
mysql-test/t/innodb_bug34300.test
mysql-test/t/max_allowed_packet_basic.test
mysql-test/t/max_allowed_packet_func.test
mysql-test/t/net_buffer_length_basic.test
mysql-test/t/packet.test
mysql-test/t/union.test
mysql-test/t/variables.test
sql/set_var.cc
sql/set_var.h
sql/share/errmsg.txt
------------------------------------------------------------
------------------------------------------------------------------------
17 years ago  branches/zip: Merge 2437:2485 from branches/5.1:
(r2478 was skipped for the obvious reason)
------------------------------------------------------------------------
r2464 | vasil | 2008-05-19 17:59:42 +0300 (Mon, 19 May 2008) | 9 lines
branches/5.1:
Fix Bug#36600 SHOW STATUS takes a lot of CPU in buf_get_latched_pages_number
by removing the Innodb_buffer_pool_pages_latched variable from
SHOW STATUS output in non-UNIV_DEBUG compilation.
Approved by: Heikki
------------------------------------------------------------------------
r2466 | calvin | 2008-05-20 01:37:14 +0300 (Tue, 20 May 2008) | 12 lines
branches/5.1:
Fix Bug#11894 innodb_file_per_table crashes w/ Windows .sym symbolic
link hack
The crash was due to un-handled error 3 (path not found). In the case
of file per table, change the call to os_file_handle_error_no_exit()
from os_file_handle_error(). Also, checks for full path pattern during
table create (Windows only), which is used in symbolic link and temp
table creation.
Approved by: Heikki
------------------------------------------------------------------------
r2478 | sunny | 2008-05-23 08:29:08 +0300 (Fri, 23 May 2008) | 3 lines
branches/5.1: Fix for bug# 36793. This is a back port from branches/zip. This
code has been tested on a big-endian machine too.
------------------------------------------------------------------------
r2480 | vasil | 2008-05-27 11:40:07 +0300 (Tue, 27 May 2008) | 11 lines
branches/5.1:
Fix Bug#36819 ut_usectime does not handle errors from gettimeofday
by retrying gettimeofday() several times if it fails in ut_usectime().
If it fails on all calls then return error to the caller to be handled
at higher level.
Update the variable innodb_row_lock_time_max in SHOW STATUS output only
if ut_usectime() was successful.
------------------------------------------------------------------------
r2482 | sunny | 2008-05-28 12:18:35 +0300 (Wed, 28 May 2008) | 5 lines
branches/5.1: Fix for Bug#35602, "Failed to read auto-increment value from
storage engine". The test for REPLACE was an error of ommission since it's
classified as a simple INSERT. For REPLACE statements we don't acquire
the special AUTOINC lock for AUTOINC_NEW_STYLE_LOCKING with this fix.
------------------------------------------------------------------------
r2485 | vasil | 2008-05-28 16:01:14 +0300 (Wed, 28 May 2008) | 9 lines
branches/5.1:
Fix Bug#36149 Read buffer overflow in srv0start.c found during "make test"
Use strncmp(3) instead of memcmp(3) to avoid reading past end of the string
if it is empty (*str == '\0'). This bug is _not_ a buffer overflow.
Discussed with: Sunny (via IM)
------------------------------------------------------------------------
18 years ago  branches/zip: Merge 2437:2485 from branches/5.1:
(r2478 was skipped for the obvious reason)
------------------------------------------------------------------------
r2464 | vasil | 2008-05-19 17:59:42 +0300 (Mon, 19 May 2008) | 9 lines
branches/5.1:
Fix Bug#36600 SHOW STATUS takes a lot of CPU in buf_get_latched_pages_number
by removing the Innodb_buffer_pool_pages_latched variable from
SHOW STATUS output in non-UNIV_DEBUG compilation.
Approved by: Heikki
------------------------------------------------------------------------
r2466 | calvin | 2008-05-20 01:37:14 +0300 (Tue, 20 May 2008) | 12 lines
branches/5.1:
Fix Bug#11894 innodb_file_per_table crashes w/ Windows .sym symbolic
link hack
The crash was due to un-handled error 3 (path not found). In the case
of file per table, change the call to os_file_handle_error_no_exit()
from os_file_handle_error(). Also, checks for full path pattern during
table create (Windows only), which is used in symbolic link and temp
table creation.
Approved by: Heikki
------------------------------------------------------------------------
r2478 | sunny | 2008-05-23 08:29:08 +0300 (Fri, 23 May 2008) | 3 lines
branches/5.1: Fix for bug# 36793. This is a back port from branches/zip. This
code has been tested on a big-endian machine too.
------------------------------------------------------------------------
r2480 | vasil | 2008-05-27 11:40:07 +0300 (Tue, 27 May 2008) | 11 lines
branches/5.1:
Fix Bug#36819 ut_usectime does not handle errors from gettimeofday
by retrying gettimeofday() several times if it fails in ut_usectime().
If it fails on all calls then return error to the caller to be handled
at higher level.
Update the variable innodb_row_lock_time_max in SHOW STATUS output only
if ut_usectime() was successful.
------------------------------------------------------------------------
r2482 | sunny | 2008-05-28 12:18:35 +0300 (Wed, 28 May 2008) | 5 lines
branches/5.1: Fix for Bug#35602, "Failed to read auto-increment value from
storage engine". The test for REPLACE was an error of ommission since it's
classified as a simple INSERT. For REPLACE statements we don't acquire
the special AUTOINC lock for AUTOINC_NEW_STYLE_LOCKING with this fix.
------------------------------------------------------------------------
r2485 | vasil | 2008-05-28 16:01:14 +0300 (Wed, 28 May 2008) | 9 lines
branches/5.1:
Fix Bug#36149 Read buffer overflow in srv0start.c found during "make test"
Use strncmp(3) instead of memcmp(3) to avoid reading past end of the string
if it is empty (*str == '\0'). This bug is _not_ a buffer overflow.
Discussed with: Sunny (via IM)
------------------------------------------------------------------------
18 years ago  branches/zip: Merge 2437:2485 from branches/5.1:
(r2478 was skipped for the obvious reason)
------------------------------------------------------------------------
r2464 | vasil | 2008-05-19 17:59:42 +0300 (Mon, 19 May 2008) | 9 lines
branches/5.1:
Fix Bug#36600 SHOW STATUS takes a lot of CPU in buf_get_latched_pages_number
by removing the Innodb_buffer_pool_pages_latched variable from
SHOW STATUS output in non-UNIV_DEBUG compilation.
Approved by: Heikki
------------------------------------------------------------------------
r2466 | calvin | 2008-05-20 01:37:14 +0300 (Tue, 20 May 2008) | 12 lines
branches/5.1:
Fix Bug#11894 innodb_file_per_table crashes w/ Windows .sym symbolic
link hack
The crash was due to un-handled error 3 (path not found). In the case
of file per table, change the call to os_file_handle_error_no_exit()
from os_file_handle_error(). Also, checks for full path pattern during
table create (Windows only), which is used in symbolic link and temp
table creation.
Approved by: Heikki
------------------------------------------------------------------------
r2478 | sunny | 2008-05-23 08:29:08 +0300 (Fri, 23 May 2008) | 3 lines
branches/5.1: Fix for bug# 36793. This is a back port from branches/zip. This
code has been tested on a big-endian machine too.
------------------------------------------------------------------------
r2480 | vasil | 2008-05-27 11:40:07 +0300 (Tue, 27 May 2008) | 11 lines
branches/5.1:
Fix Bug#36819 ut_usectime does not handle errors from gettimeofday
by retrying gettimeofday() several times if it fails in ut_usectime().
If it fails on all calls then return error to the caller to be handled
at higher level.
Update the variable innodb_row_lock_time_max in SHOW STATUS output only
if ut_usectime() was successful.
------------------------------------------------------------------------
r2482 | sunny | 2008-05-28 12:18:35 +0300 (Wed, 28 May 2008) | 5 lines
branches/5.1: Fix for Bug#35602, "Failed to read auto-increment value from
storage engine". The test for REPLACE was an error of ommission since it's
classified as a simple INSERT. For REPLACE statements we don't acquire
the special AUTOINC lock for AUTOINC_NEW_STYLE_LOCKING with this fix.
------------------------------------------------------------------------
r2485 | vasil | 2008-05-28 16:01:14 +0300 (Wed, 28 May 2008) | 9 lines
branches/5.1:
Fix Bug#36149 Read buffer overflow in srv0start.c found during "make test"
Use strncmp(3) instead of memcmp(3) to avoid reading past end of the string
if it is empty (*str == '\0'). This bug is _not_ a buffer overflow.
Discussed with: Sunny (via IM)
------------------------------------------------------------------------
18 years ago  branches/zip: Merge 2437:2485 from branches/5.1:
(r2478 was skipped for the obvious reason)
------------------------------------------------------------------------
r2464 | vasil | 2008-05-19 17:59:42 +0300 (Mon, 19 May 2008) | 9 lines
branches/5.1:
Fix Bug#36600 SHOW STATUS takes a lot of CPU in buf_get_latched_pages_number
by removing the Innodb_buffer_pool_pages_latched variable from
SHOW STATUS output in non-UNIV_DEBUG compilation.
Approved by: Heikki
------------------------------------------------------------------------
r2466 | calvin | 2008-05-20 01:37:14 +0300 (Tue, 20 May 2008) | 12 lines
branches/5.1:
Fix Bug#11894 innodb_file_per_table crashes w/ Windows .sym symbolic
link hack
The crash was due to un-handled error 3 (path not found). In the case
of file per table, change the call to os_file_handle_error_no_exit()
from os_file_handle_error(). Also, checks for full path pattern during
table create (Windows only), which is used in symbolic link and temp
table creation.
Approved by: Heikki
------------------------------------------------------------------------
r2478 | sunny | 2008-05-23 08:29:08 +0300 (Fri, 23 May 2008) | 3 lines
branches/5.1: Fix for bug# 36793. This is a back port from branches/zip. This
code has been tested on a big-endian machine too.
------------------------------------------------------------------------
r2480 | vasil | 2008-05-27 11:40:07 +0300 (Tue, 27 May 2008) | 11 lines
branches/5.1:
Fix Bug#36819 ut_usectime does not handle errors from gettimeofday
by retrying gettimeofday() several times if it fails in ut_usectime().
If it fails on all calls then return error to the caller to be handled
at higher level.
Update the variable innodb_row_lock_time_max in SHOW STATUS output only
if ut_usectime() was successful.
------------------------------------------------------------------------
r2482 | sunny | 2008-05-28 12:18:35 +0300 (Wed, 28 May 2008) | 5 lines
branches/5.1: Fix for Bug#35602, "Failed to read auto-increment value from
storage engine". The test for REPLACE was an error of ommission since it's
classified as a simple INSERT. For REPLACE statements we don't acquire
the special AUTOINC lock for AUTOINC_NEW_STYLE_LOCKING with this fix.
------------------------------------------------------------------------
r2485 | vasil | 2008-05-28 16:01:14 +0300 (Wed, 28 May 2008) | 9 lines
branches/5.1:
Fix Bug#36149 Read buffer overflow in srv0start.c found during "make test"
Use strncmp(3) instead of memcmp(3) to avoid reading past end of the string
if it is empty (*str == '\0'). This bug is _not_ a buffer overflow.
Discussed with: Sunny (via IM)
------------------------------------------------------------------------
18 years ago  branches/zip: Merge 2437:2485 from branches/5.1:
(r2478 was skipped for the obvious reason)
------------------------------------------------------------------------
r2464 | vasil | 2008-05-19 17:59:42 +0300 (Mon, 19 May 2008) | 9 lines
branches/5.1:
Fix Bug#36600 SHOW STATUS takes a lot of CPU in buf_get_latched_pages_number
by removing the Innodb_buffer_pool_pages_latched variable from
SHOW STATUS output in non-UNIV_DEBUG compilation.
Approved by: Heikki
------------------------------------------------------------------------
r2466 | calvin | 2008-05-20 01:37:14 +0300 (Tue, 20 May 2008) | 12 lines
branches/5.1:
Fix Bug#11894 innodb_file_per_table crashes w/ Windows .sym symbolic
link hack
The crash was due to un-handled error 3 (path not found). In the case
of file per table, change the call to os_file_handle_error_no_exit()
from os_file_handle_error(). Also, checks for full path pattern during
table create (Windows only), which is used in symbolic link and temp
table creation.
Approved by: Heikki
------------------------------------------------------------------------
r2478 | sunny | 2008-05-23 08:29:08 +0300 (Fri, 23 May 2008) | 3 lines
branches/5.1: Fix for bug# 36793. This is a back port from branches/zip. This
code has been tested on a big-endian machine too.
------------------------------------------------------------------------
r2480 | vasil | 2008-05-27 11:40:07 +0300 (Tue, 27 May 2008) | 11 lines
branches/5.1:
Fix Bug#36819 ut_usectime does not handle errors from gettimeofday
by retrying gettimeofday() several times if it fails in ut_usectime().
If it fails on all calls then return error to the caller to be handled
at higher level.
Update the variable innodb_row_lock_time_max in SHOW STATUS output only
if ut_usectime() was successful.
------------------------------------------------------------------------
r2482 | sunny | 2008-05-28 12:18:35 +0300 (Wed, 28 May 2008) | 5 lines
branches/5.1: Fix for Bug#35602, "Failed to read auto-increment value from
storage engine". The test for REPLACE was an error of ommission since it's
classified as a simple INSERT. For REPLACE statements we don't acquire
the special AUTOINC lock for AUTOINC_NEW_STYLE_LOCKING with this fix.
------------------------------------------------------------------------
r2485 | vasil | 2008-05-28 16:01:14 +0300 (Wed, 28 May 2008) | 9 lines
branches/5.1:
Fix Bug#36149 Read buffer overflow in srv0start.c found during "make test"
Use strncmp(3) instead of memcmp(3) to avoid reading past end of the string
if it is empty (*str == '\0'). This bug is _not_ a buffer overflow.
Discussed with: Sunny (via IM)
------------------------------------------------------------------------
18 years ago |
|
/******************************************************
The database server main program
NOTE: SQL Server 7 uses something which the documentationcalls user mode scheduled threads (UMS threads). One suchthread is usually allocated per processor. Win32documentation does not know any UMS threads, which suggeststhat the concept is internal to SQL Server 7. It may mean thatSQL Server 7 does all the scheduling of threads itself, evenin i/o waits. We should maybe modify InnoDB to use the sametechnique, because thread switches within NT may be too slow.
SQL Server 7 also mentions fibers, which are cooperativelyscheduled threads. They can boost performance by 5 %,according to the Delaney and Soukup's book.
Windows 2000 will have something called thread pooling(see msdn website), which we could possibly use.
Another possibility could be to use some very fast user spacethread library. This might confuse NT though.
(c) 1995 Innobase Oy
Created 10/8/1995 Heikki Tuuri*******************************************************//***********************************************************************
# Copyright (c) 2008, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials
# provided with the distribution.
# * Neither the name of the Google Inc. nor the names of its
# contributors may be used to endorse or promote products
# derived from this software without specific prior written
# permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# Note, the BSD license applies to the new code. The old code is GPL.
***********************************************************************//* Dummy comment */#include "srv0srv.h"
#include "ut0mem.h"
#include "ut0ut.h"
#include "os0proc.h"
#include "mem0mem.h"
#include "mem0pool.h"
#include "sync0sync.h"
#include "thr0loc.h"
#include "que0que.h"
#include "srv0que.h"
#include "log0recv.h"
#include "pars0pars.h"
#include "usr0sess.h"
#include "lock0lock.h"
#include "trx0purge.h"
#include "ibuf0ibuf.h"
#include "buf0flu.h"
#include "buf0lru.h"
#include "btr0sea.h"
#include "dict0load.h"
#include "dict0boot.h"
#include "srv0start.h"
#include "row0mysql.h"
#include "ha_prototypes.h"
#include "trx0i_s.h"
/* This is set to TRUE if the MySQL user has set it in MySQL; currently
affects only FOREIGN KEY definition parsing */UNIV_INTERN ibool srv_lower_case_table_names = FALSE;
/* The following counter is incremented whenever there is some user activity
in the server */UNIV_INTERN ulint srv_activity_count = 0;
/* The following is the maximum allowed duration of a lock wait. */UNIV_INTERN ulint srv_fatal_semaphore_wait_threshold = 600;
/* How much data manipulation language (DML) statements need to be delayed,
in microseconds, in order to reduce the lagging of the purge thread. */UNIV_INTERN ulint srv_dml_needed_delay = 0;
UNIV_INTERN ibool srv_lock_timeout_and_monitor_active = FALSE;UNIV_INTERN ibool srv_error_monitor_active = FALSE;
UNIV_INTERN const char* srv_main_thread_op_info = "";
/* Prefix used by MySQL to indicate pre-5.1 table name encoding */UNIV_INTERN const char srv_mysql50_table_name_prefix[9] = "#mysql50#";
/* Server parameters which are read from the initfile */
/* The following three are dir paths which are catenated before file
names, where the file name itself may also contain a path */
UNIV_INTERN char* srv_data_home = NULL;#ifdef UNIV_LOG_ARCHIVE
UNIV_INTERN char* srv_arch_dir = NULL;#endif /* UNIV_LOG_ARCHIVE */
/* store to its own file each table created by an user; data
dictionary tables are in the system tablespace 0 */UNIV_INTERN my_bool srv_file_per_table;/* The file format to use on new *.ibd files. */UNIV_INTERN ulint srv_file_format = 0;/* Whether to check file format during startup a value of
DICT_TF_FORMAT_MAX + 1 means no checking ie. FALSE. The default is toset it to the highest format we support. */UNIV_INTERN ulint srv_check_file_format_at_startup = DICT_TF_FORMAT_MAX;
#if DICT_TF_FORMAT_51
# error "DICT_TF_FORMAT_51 must be 0!"
#endif
/* Place locks to records only i.e. do not use next-key locking except
on duplicate key checking and foreign key checking */UNIV_INTERN ibool srv_locks_unsafe_for_binlog = FALSE;
UNIV_INTERN ulint srv_n_data_files = 0;UNIV_INTERN char** srv_data_file_names = NULL;/* size in database pages */UNIV_INTERN ulint* srv_data_file_sizes = NULL;
/* if TRUE, then we auto-extend the last data file */UNIV_INTERN ibool srv_auto_extend_last_data_file = FALSE;/* if != 0, this tells the max size auto-extending may increase the
last data file size */UNIV_INTERN ulint srv_last_file_size_max = 0;/* If the last data file is auto-extended, we add this
many pages to it at a time */UNIV_INTERN ulong srv_auto_extend_increment = 8;UNIV_INTERN ulint* srv_data_file_is_raw_partition = NULL;
/* If the following is TRUE we do not allow inserts etc. This protects
the user from forgetting the 'newraw' keyword to my.cnf */
UNIV_INTERN ibool srv_created_new_raw = FALSE;
UNIV_INTERN char** srv_log_group_home_dirs = NULL;
UNIV_INTERN ulint srv_n_log_groups = ULINT_MAX;UNIV_INTERN ulint srv_n_log_files = ULINT_MAX;/* size in database pages */UNIV_INTERN ulint srv_log_file_size = ULINT_MAX;/* size in database pages */UNIV_INTERN ulint srv_log_buffer_size = ULINT_MAX;UNIV_INTERN ulong srv_flush_log_at_trx_commit = 1;
/* The sort order table of the MySQL latin1_swedish_ci character set
collation */UNIV_INTERN const byte* srv_latin1_ordering;
/* use os/external memory allocator */UNIV_INTERN my_bool srv_use_sys_malloc = FALSE;/* requested size in kilobytes */UNIV_INTERN ulint srv_buf_pool_size = ULINT_MAX;/* previously requested size */UNIV_INTERN ulint srv_buf_pool_old_size;/* current size in kilobytes */UNIV_INTERN ulint srv_buf_pool_curr_size = 0;/* size in bytes */UNIV_INTERN ulint srv_mem_pool_size = ULINT_MAX;UNIV_INTERN ulint srv_lock_table_size = ULINT_MAX;
UNIV_INTERN ulint srv_n_file_io_threads = ULINT_MAX;
#ifdef UNIV_LOG_ARCHIVE
UNIV_INTERN ibool srv_log_archive_on = FALSE;UNIV_INTERN ibool srv_archive_recovery = 0;UNIV_INTERN ib_uint64_t srv_archive_recovery_limit_lsn;#endif /* UNIV_LOG_ARCHIVE */
/* This parameter is used to throttle the number of insert buffers that are
merged in a batch. By increasing this parameter on a faster disk you canpossibly reduce the number of I/O operations performed to complete themerge operation. The value of this parameter is used as is by thebackground loop when the system is idle (low load), on a busy systemthe parameter is scaled down by a factor of 4, this is to avoid puttinga heavier load on the I/O sub system. */
UNIV_INTERN ulong srv_insert_buffer_batch_size = 20;
UNIV_INTERN char* srv_file_flush_method_str = NULL;UNIV_INTERN ulint srv_unix_file_flush_method = SRV_UNIX_FSYNC;UNIV_INTERN ulint srv_win_file_flush_method = SRV_WIN_IO_UNBUFFERED;
UNIV_INTERN ulint srv_max_n_open_files = 300;
/* The InnoDB main thread tries to keep the ratio of modified pages
in the buffer pool to all database pages in the buffer pool smaller thanthe following number. But it is not guaranteed that the value stays belowthat during a time of heavy update/insert activity. */
UNIV_INTERN ulong srv_max_buf_pool_modified_pct = 90;
/* variable counts amount of data read in total (in bytes) */UNIV_INTERN ulint srv_data_read = 0;
/* here we count the amount of data written in total (in bytes) */UNIV_INTERN ulint srv_data_written = 0;
/* the number of the log write requests done */UNIV_INTERN ulint srv_log_write_requests = 0;
/* the number of physical writes to the log performed */UNIV_INTERN ulint srv_log_writes = 0;
/* amount of data written to the log files in bytes */UNIV_INTERN ulint srv_os_log_written = 0;
/* amount of writes being done to the log files */UNIV_INTERN ulint srv_os_log_pending_writes = 0;
/* we increase this counter, when there we don't have enough space in the
log buffer and have to flush it */UNIV_INTERN ulint srv_log_waits = 0;
/* this variable counts the amount of times, when the doublewrite buffer
was flushed */UNIV_INTERN ulint srv_dblwr_writes = 0;
/* here we store the number of pages that have been flushed to the
doublewrite buffer */UNIV_INTERN ulint srv_dblwr_pages_written = 0;
/* in this variable we store the number of write requests issued */UNIV_INTERN ulint srv_buf_pool_write_requests = 0;
/* here we store the number of times when we had to wait for a free page
in the buffer pool. It happens when the buffer pool is full and we needto make a flush, in order to be able to read or create a page. */UNIV_INTERN ulint srv_buf_pool_wait_free = 0;
/* variable to count the number of pages that were written from buffer
pool to the disk */UNIV_INTERN ulint srv_buf_pool_flushed = 0;
/* variable to count the number of buffer pool reads that led to the
reading of a disk page */UNIV_INTERN ulint srv_buf_pool_reads = 0;
/* variable to count the number of sequential read-aheads */UNIV_INTERN ulint srv_read_ahead_seq = 0;
/* variable to count the number of random read-aheads */UNIV_INTERN ulint srv_read_ahead_rnd = 0;
/* structure to pass status variables to MySQL */UNIV_INTERN export_struc export_vars;
/* If the following is != 0 we do not allow inserts etc. This protects
the user from forgetting the innodb_force_recovery keyword to my.cnf */
UNIV_INTERN ulint srv_force_recovery = 0;/*-----------------------*//* We are prepared for a situation that we have this many threads waiting for
a semaphore inside InnoDB. innobase_start_or_create_for_mysql() sets thevalue. */
UNIV_INTERN ulint srv_max_n_threads = 0;
/* The following controls how many threads we let inside InnoDB concurrently:
threads waiting for locks are not counted into the number because otherwisewe could get a deadlock. MySQL creates a thread for each user session, andsemaphore contention and convoy problems can occur withput this restriction.Value 10 should be good if there are less than 4 processors + 4 disks in thecomputer. Bigger computers need bigger values. Value 0 will disable theconcurrency check. */
UNIV_INTERN ulong srv_thread_concurrency = 0;UNIV_INTERN ulong srv_commit_concurrency = 0;
/* this mutex protects srv_conc data structures */UNIV_INTERN os_fast_mutex_t srv_conc_mutex;/* number of transactions that have declared_to_be_inside_innodb set.
It used to be a non-error for this value to drop below zero temporarily.This is no longer true. We'll, however, keep the lint datatype to addassertions to catch any corner cases that we may have missed. */UNIV_INTERN lint srv_conc_n_threads = 0;/* number of OS threads waiting in the FIFO for a permission to enter
InnoDB */UNIV_INTERN ulint srv_conc_n_waiting_threads = 0;
typedef struct srv_conc_slot_struct srv_conc_slot_t;struct srv_conc_slot_struct{ os_event_t event; /* event to wait */ ibool reserved; /* TRUE if slot
reserved */ ibool wait_ended; /* TRUE when another
thread has already set the event and the thread in this slot is free to proceed; but reserved may still be TRUE at that point */ UT_LIST_NODE_T(srv_conc_slot_t) srv_conc_queue; /* queue node */};
/* queue of threads waiting to get in */UNIV_INTERN UT_LIST_BASE_NODE_T(srv_conc_slot_t) srv_conc_queue;/* array of wait slots */UNIV_INTERN srv_conc_slot_t* srv_conc_slots;
/* Number of times a thread is allowed to enter InnoDB within the same
SQL query after it has once got the ticket at srv_conc_enter_innodb */#define SRV_FREE_TICKETS_TO_ENTER srv_n_free_tickets_to_enter
#define SRV_THREAD_SLEEP_DELAY srv_thread_sleep_delay
/*-----------------------*//* If the following is set to 1 then we do not run purge and insert buffer
merge to completion before shutdown. If it is set to 2, do not even flush thebuffer pool to data files at the shutdown: we effectively 'crash'InnoDB (but lose no committed transactions). */UNIV_INTERN ulint srv_fast_shutdown = 0;
/* Generate a innodb_status.<pid> file */UNIV_INTERN ibool srv_innodb_status = FALSE;
/* When estimating number of different key values in an index, sample
this many index pages */UNIV_INTERN unsigned long long srv_stats_sample_pages = 8;
UNIV_INTERN ibool srv_use_doublewrite_buf = TRUE;UNIV_INTERN ibool srv_use_checksums = TRUE;
UNIV_INTERN ibool srv_set_thread_priorities = TRUE;UNIV_INTERN int srv_query_thread_priority = 0;
UNIV_INTERN ulong srv_replication_delay = 0;
/*-------------------------------------------*/UNIV_INTERN ulong srv_n_spin_wait_rounds = 20;UNIV_INTERN ulong srv_n_free_tickets_to_enter = 500;UNIV_INTERN ulong srv_thread_sleep_delay = 10000;UNIV_INTERN ulint srv_spin_wait_delay = 5;UNIV_INTERN ibool srv_priority_boost = TRUE;
#ifdef UNIV_DEBUG
UNIV_INTERN ibool srv_print_thread_releases = FALSE;UNIV_INTERN ibool srv_print_lock_waits = FALSE;UNIV_INTERN ibool srv_print_buf_io = FALSE;UNIV_INTERN ibool srv_print_log_io = FALSE;UNIV_INTERN ibool srv_print_latch_waits = FALSE;#endif /* UNIV_DEBUG */
UNIV_INTERN ulint srv_n_rows_inserted = 0;UNIV_INTERN ulint srv_n_rows_updated = 0;UNIV_INTERN ulint srv_n_rows_deleted = 0;UNIV_INTERN ulint srv_n_rows_read = 0;#ifndef UNIV_HOTBACKUP
static ulint srv_n_rows_inserted_old = 0;static ulint srv_n_rows_updated_old = 0;static ulint srv_n_rows_deleted_old = 0;static ulint srv_n_rows_read_old = 0;#endif /* !UNIV_HOTBACKUP */
UNIV_INTERN ulint srv_n_lock_wait_count = 0;UNIV_INTERN ulint srv_n_lock_wait_current_count = 0;UNIV_INTERN ib_int64_t srv_n_lock_wait_time = 0;UNIV_INTERN ulint srv_n_lock_max_wait_time = 0;
/*
Set the following to 0 if you want InnoDB to write messages on stderr on startup/shutdown*/UNIV_INTERN ibool srv_print_verbose_log = TRUE;UNIV_INTERN ibool srv_print_innodb_monitor = FALSE;UNIV_INTERN ibool srv_print_innodb_lock_monitor = FALSE;UNIV_INTERN ibool srv_print_innodb_tablespace_monitor = FALSE;UNIV_INTERN ibool srv_print_innodb_table_monitor = FALSE;
/* Array of English strings describing the current state of an
i/o handler thread */
UNIV_INTERN const char* srv_io_thread_op_info[SRV_MAX_N_IO_THREADS];UNIV_INTERN const char* srv_io_thread_function[SRV_MAX_N_IO_THREADS];
UNIV_INTERN time_t srv_last_monitor_time;
UNIV_INTERN mutex_t srv_innodb_monitor_mutex;
/* Mutex for locking srv_monitor_file */UNIV_INTERN mutex_t srv_monitor_file_mutex;/* Temporary file for innodb monitor output */UNIV_INTERN FILE* srv_monitor_file;/* Mutex for locking srv_dict_tmpfile.
This mutex has a very high rank; threads reserving it should notbe holding any InnoDB latches. */UNIV_INTERN mutex_t srv_dict_tmpfile_mutex;/* Temporary file for output from the data dictionary */UNIV_INTERN FILE* srv_dict_tmpfile;/* Mutex for locking srv_misc_tmpfile.
This mutex has a very low rank; threads reserving it should notacquire any further latches or sleep before releasing this one. */UNIV_INTERN mutex_t srv_misc_tmpfile_mutex;/* Temporary file for miscellanous diagnostic output */UNIV_INTERN FILE* srv_misc_tmpfile;
UNIV_INTERN ulint srv_main_thread_process_no = 0;UNIV_INTERN ulint srv_main_thread_id = 0;
/*
IMPLEMENTATION OF THE SERVER MAIN PROGRAM =========================================
There is the following analogue between this databaseserver and an operating system kernel:
DB concept equivalent OS concept---------- ---------------------transaction -- process;
query thread -- thread;
lock -- semaphore;
transaction set tothe rollback state -- kill signal delivered to a process;
kernel -- kernel;
query thread execution:(a) without kernel mutexreserved -- process executing in user mode;(b) with kernel mutex reserved -- process executing in kernel mode;
The server is controlled by a master thread which runs ata priority higher than normal, that is, higher than user threads.It sleeps most of the time, and wakes up, say, every 300 milliseconds,to check whether there is anything happening in the server whichrequires intervention of the master thread. Such situations may be,for example, when flushing of dirty blocks is needed in the bufferpool or old version of database rows have to be cleaned away.
The threads which we call user threads serve the queries ofthe clients and input from the console of the server.They run at normal priority. The server may have severalcommunications endpoints. A dedicated set of user threads waitsat each of these endpoints ready to receive a client request.Each request is taken by a single user thread, which then startsprocessing and, when the result is ready, sends it to the clientand returns to wait at the same endpoint the thread started from.
So, we do not have dedicated communication threads listening atthe endpoints and dealing the jobs to dedicated worker threads.Our architecture saves one thread swithch per request, comparedto the solution with dedicated communication threadswhich amounts to 15 microseconds on 100 MHz Pentiumrunning NT. If the clientis communicating over a network, this saving is negligible, butif the client resides in the same machine, maybe in an SMP machineon a different processor from the server thread, the savingcan be important as the threads can communicate over sharedmemory with an overhead of a few microseconds.
We may later implement a dedicated communication thread solutionfor those endpoints which communicate over a network.
Our solution with user threads has two problems: for each endpointthere has to be a number of listening threads. If there are manycommunication endpoints, it may be difficult to set the right numberof concurrent threads in the system, as many of the threadsmay always be waiting at less busy endpoints. Another problemis queuing of the messages, as the server internally does notoffer any queue for jobs.
Another group of user threads is intended for splitting thequeries and processing them in parallel. Let us call theseparallel communication threads. These threads are waiting forparallelized tasks, suspended on event semaphores.
A single user thread waits for input from the console,like a command to shut the database.
Utility threads are a different group of threads which takescare of the buffer pool flushing and other, mainly backgroundoperations, in the server.Some of these utility threads always run at a lower than normalpriority, so that they are always in background. Some of themmay dynamically boost their priority by the pri_adjust function,even to higher than normal priority, if their task becomes urgent.The running of utilities is controlled by high- and low-water marksof urgency. The urgency may be measured by the number of dirty blocksin the buffer pool, in the case of the flush thread, for example.When the high-water mark is exceeded, an utility starts running, untilthe urgency drops under the low-water mark. Then the utility threadsuspend itself to wait for an event. The master thread isresponsible of signaling this event when the utility thread isagain needed.
For each individual type of utility, some threads always remainat lower than normal priority. This is because pri_adjust is implementedso that the threads at normal or higher priority control theirshare of running time by calling sleep. Thus, if the load of thesystem sudenly drops, these threads cannot necessarily utilizethe system fully. The background priority threads make up for this,starting to run when the load drops.
When there is no activity in the system, also the master threadsuspends itself to wait for an event makingthe server totally silent. The responsibility to signal thisevent is on the user thread which again receives a messagefrom a client.
There is still one complication in our server design. If abackground utility thread obtains a resource (e.g., mutex) needed by a userthread, and there is also some other user activity in the system,the user thread may have to wait indefinitely long for theresource, as the OS does not schedule a background thread ifthere is some other runnable user thread. This problem is calledpriority inversion in real-time programming.
One solution to the priority inversion problem would be tokeep record of which thread owns which resource andin the above case boost the priority of the background threadso that it will be scheduled and it can release the resource.This solution is called priority inheritance in real-time programming.A drawback of this solution is that the overhead of acquiring a mutexincreases slightly, maybe 0.2 microseconds on a 100 MHz Pentium, becausethe thread has to call os_thread_get_curr_id.This may be compared to 0.5 microsecond overhead for a mutex lock-unlockpair. Note that the threadcannot store the information in the resource, say mutex, itself,because competing threads could wipe out the information if it isstored before acquiring the mutex, and if it stored afterwards,the information is outdated for the time of one machine instruction,at least. (To be precise, the information could be stored tolock_word in mutex if the machine supports atomic swap.)
The above solution with priority inheritance may become actual in thefuture, but at the moment we plan to implement a more coarse solution,which could be called a global priority inheritance. If a threadhas to wait for a long time, say 300 milliseconds, for a resource,we just guess that it may be waiting for a resource owned by a backgroundthread, and boost the the priority of all runnable background threadsto the normal level. The background threads then themselves adjusttheir fixed priority back to background after releasing all resourcesthey had (or, at some fixed points in their program code).
What is the performance of the global priority inheritance solution?We may weigh the length of the wait time 300 milliseconds, duringwhich the system processes some other threadto the cost of boosting the priority of each runnable backgroundthread, rescheduling it, and lowering the priority again.On 100 MHz Pentium + NT this overhead may be of the order 100microseconds per thread. So, if the number of runnable backgroundthreads is not very big, say < 100, the cost is tolerable.Utility threads probably will access resources used byuser threads not very often, so collisions of user threadsto preempted utility threads should not happen very often.
The thread table containsinformation of the current status of each thread existing in the system,and also the event semaphores used in suspending the master threadand utility and parallel communication threads when they have nothing to do.The thread table can be seen as an analogue to the process tablein a traditional Unix implementation.
The thread table is also used in the global priority inheritancescheme. This brings in one additional complication: threads accessingthe thread table must have at least normal fixed priority,because the priority inheritance solution does not work if a backgroundthread is preempted while possessing the mutex protecting the thread table.So, if a thread accesses the thread table, its priority has to beboosted at least to normal. This priority requirement can be seen similar tothe privileged mode used when processing the kernel calls in traditionalUnix.*/
/* Thread slot in the thread table */struct srv_slot_struct{ os_thread_id_t id; /* thread id */ os_thread_t handle; /* thread handle */ unsigned type:3; /* thread type: user, utility etc. */ unsigned in_use:1; /* TRUE if this slot is in use */ unsigned suspended:1; /* TRUE if the thread is waiting
for the event of this slot */ ib_time_t suspend_time; /* time when the thread was
suspended */ os_event_t event; /* event used in suspending the
thread when it has nothing to do */ que_thr_t* thr; /* suspended query thread (only
used for MySQL threads) */};
/* Table for MySQL threads where they will be suspended to wait for locks */UNIV_INTERN srv_slot_t* srv_mysql_table = NULL;
UNIV_INTERN os_event_t srv_lock_timeout_thread_event;
UNIV_INTERN srv_sys_t* srv_sys = NULL;
/* padding to prevent other memory update hotspots from residing on
the same memory cache line */UNIV_INTERN byte srv_pad1[64];/* mutex protecting the server, trx structs, query threads, and lock table */UNIV_INTERN mutex_t* kernel_mutex_temp;/* padding to prevent other memory update hotspots from residing on
the same memory cache line */UNIV_INTERN byte srv_pad2[64];
#if 0
/* The following three values measure the urgency of the jobs of
buffer, version, and insert threads. They may vary from 0 - 1000.The server mutex protects all these variables. The low-water valuestell that the server can acquiesce the utility when the valuedrops below this low-water mark. */
static ulint srv_meter[SRV_MASTER + 1];static ulint srv_meter_low_water[SRV_MASTER + 1];static ulint srv_meter_high_water[SRV_MASTER + 1];static ulint srv_meter_high_water2[SRV_MASTER + 1];static ulint srv_meter_foreground[SRV_MASTER + 1];#endif
/* The following values give info about the activity going on in
the database. They are protected by the server mutex. The arraysare indexed by the type of the thread. */
UNIV_INTERN ulint srv_n_threads_active[SRV_MASTER + 1];UNIV_INTERN ulint srv_n_threads[SRV_MASTER + 1];
/*************************************************************************
Sets the info describing an i/o thread current state. */UNIV_INTERNvoidsrv_set_io_thread_op_info(/*======================*/ ulint i, /* in: the 'segment' of the i/o thread */ const char* str) /* in: constant char string describing the
state */{ ut_a(i < SRV_MAX_N_IO_THREADS);
srv_io_thread_op_info[i] = str;}
/*************************************************************************
Accessor function to get pointer to n'th slot in the server threadtable. */staticsrv_slot_t*srv_table_get_nth_slot(/*===================*/ /* out: pointer to the slot */ ulint index) /* in: index of the slot */{ ut_a(index < OS_THREAD_MAX_N);
return(srv_sys->threads + index);}
#ifndef UNIV_HOTBACKUP
/*************************************************************************
Gets the number of threads in the system. */UNIV_INTERNulintsrv_get_n_threads(void)/*===================*/{ ulint i; ulint n_threads = 0;
mutex_enter(&kernel_mutex);
for (i = SRV_COM; i < SRV_MASTER + 1; i++) {
n_threads += srv_n_threads[i]; }
mutex_exit(&kernel_mutex);
return(n_threads);}
/*************************************************************************
Reserves a slot in the thread table for the current thread. Also creates thethread local storage struct for the current thread. NOTE! The server mutexhas to be reserved by the caller! */staticulintsrv_table_reserve_slot(/*===================*/ /* out: reserved slot index */ enum srv_thread_type type) /* in: type of the thread */{ srv_slot_t* slot; ulint i;
ut_a(type > 0); ut_a(type <= SRV_MASTER);
i = 0; slot = srv_table_get_nth_slot(i);
while (slot->in_use) { i++; slot = srv_table_get_nth_slot(i); }
ut_a(slot->in_use == FALSE);
slot->in_use = TRUE; slot->suspended = FALSE; slot->type = type; slot->id = os_thread_get_curr_id(); slot->handle = os_thread_get_curr();
thr_local_create();
thr_local_set_slot_no(os_thread_get_curr_id(), i);
return(i);}
/*************************************************************************
Suspends the calling thread to wait for the event in its thread slot.NOTE! The server mutex has to be reserved by the caller! */staticos_event_tsrv_suspend_thread(void)/*====================*/ /* out: event for the calling thread to wait */{ srv_slot_t* slot; os_event_t event; ulint slot_no; enum srv_thread_type type;
ut_ad(mutex_own(&kernel_mutex));
slot_no = thr_local_get_slot_no(os_thread_get_curr_id());
if (srv_print_thread_releases) { fprintf(stderr, "Suspending thread %lu to slot %lu\n", (ulong) os_thread_get_curr_id(), (ulong) slot_no); }
slot = srv_table_get_nth_slot(slot_no);
type = slot->type;
ut_ad(type >= SRV_WORKER); ut_ad(type <= SRV_MASTER);
event = slot->event;
slot->suspended = TRUE;
ut_ad(srv_n_threads_active[type] > 0);
srv_n_threads_active[type]--;
os_event_reset(event);
return(event);}#endif /* !UNIV_HOTBACKUP */
/*************************************************************************
Releases threads of the type given from suspension in the thread table.NOTE! The server mutex has to be reserved by the caller! */UNIV_INTERNulintsrv_release_threads(/*================*/ /* out: number of threads
released: this may be < n if not enough threads were suspended at the moment */ enum srv_thread_type type, /* in: thread type */ ulint n) /* in: number of threads to release */{ srv_slot_t* slot; ulint i; ulint count = 0;
ut_ad(type >= SRV_WORKER); ut_ad(type <= SRV_MASTER); ut_ad(n > 0); ut_ad(mutex_own(&kernel_mutex));
for (i = 0; i < OS_THREAD_MAX_N; i++) {
slot = srv_table_get_nth_slot(i);
if (slot->in_use && slot->type == type && slot->suspended) {
slot->suspended = FALSE;
srv_n_threads_active[type]++;
os_event_set(slot->event);
if (srv_print_thread_releases) { fprintf(stderr, "Releasing thread %lu type %lu" " from slot %lu\n", (ulong) slot->id, (ulong) type, (ulong) i); }
count++;
if (count == n) { break; } } }
return(count);}
/*************************************************************************
Returns the calling thread type. */UNIV_INTERNenum srv_thread_typesrv_get_thread_type(void)/*=====================*/ /* out: SRV_COM, ... */{ ulint slot_no; srv_slot_t* slot; enum srv_thread_type type;
mutex_enter(&kernel_mutex);
slot_no = thr_local_get_slot_no(os_thread_get_curr_id());
slot = srv_table_get_nth_slot(slot_no);
type = slot->type;
ut_ad(type >= SRV_WORKER); ut_ad(type <= SRV_MASTER);
mutex_exit(&kernel_mutex);
return(type);}
/*************************************************************************
Initializes the server. */UNIV_INTERNvoidsrv_init(void)/*==========*/{ srv_conc_slot_t* conc_slot; srv_slot_t* slot; dict_table_t* table; ulint i;
srv_sys = mem_alloc(sizeof(srv_sys_t));
kernel_mutex_temp = mem_alloc(sizeof(mutex_t)); mutex_create(&kernel_mutex, SYNC_KERNEL);
mutex_create(&srv_innodb_monitor_mutex, SYNC_NO_ORDER_CHECK);
srv_sys->threads = mem_alloc(OS_THREAD_MAX_N * sizeof(srv_slot_t));
for (i = 0; i < OS_THREAD_MAX_N; i++) { slot = srv_table_get_nth_slot(i); slot->in_use = FALSE; slot->type=0; /* Avoid purify errors */ slot->event = os_event_create(NULL); ut_a(slot->event); }
srv_mysql_table = mem_alloc(OS_THREAD_MAX_N * sizeof(srv_slot_t));
for (i = 0; i < OS_THREAD_MAX_N; i++) { slot = srv_mysql_table + i; slot->in_use = FALSE; slot->type = 0; slot->event = os_event_create(NULL); ut_a(slot->event); }
srv_lock_timeout_thread_event = os_event_create(NULL);
for (i = 0; i < SRV_MASTER + 1; i++) { srv_n_threads_active[i] = 0; srv_n_threads[i] = 0;#if 0
srv_meter[i] = 30; srv_meter_low_water[i] = 50; srv_meter_high_water[i] = 100; srv_meter_high_water2[i] = 200; srv_meter_foreground[i] = 250;#endif
}
UT_LIST_INIT(srv_sys->tasks);
/* create dummy table and index for old-style infimum and supremum */ table = dict_mem_table_create("SYS_DUMMY1", DICT_HDR_SPACE, 1, 0); dict_mem_table_add_col(table, NULL, NULL, DATA_CHAR, DATA_ENGLISH | DATA_NOT_NULL, 8);
srv_sys->dummy_ind1 = dict_mem_index_create( "SYS_DUMMY1", "SYS_DUMMY1", DICT_HDR_SPACE, 0, 1); dict_index_add_col(srv_sys->dummy_ind1, table, dict_table_get_nth_col(table, 0), 0); srv_sys->dummy_ind1->table = table; /* create dummy table and index for new-style infimum and supremum */ table = dict_mem_table_create("SYS_DUMMY2", DICT_HDR_SPACE, 1, DICT_TF_COMPACT); dict_mem_table_add_col(table, NULL, NULL, DATA_CHAR, DATA_ENGLISH | DATA_NOT_NULL, 8); srv_sys->dummy_ind2 = dict_mem_index_create( "SYS_DUMMY2", "SYS_DUMMY2", DICT_HDR_SPACE, 0, 1); dict_index_add_col(srv_sys->dummy_ind2, table, dict_table_get_nth_col(table, 0), 0); srv_sys->dummy_ind2->table = table;
/* avoid ut_ad(index->cached) in dict_index_get_n_unique_in_tree */ srv_sys->dummy_ind1->cached = srv_sys->dummy_ind2->cached = TRUE;
/* Init the server concurrency restriction data structures */
os_fast_mutex_init(&srv_conc_mutex);
UT_LIST_INIT(srv_conc_queue);
srv_conc_slots = mem_alloc(OS_THREAD_MAX_N * sizeof(srv_conc_slot_t));
for (i = 0; i < OS_THREAD_MAX_N; i++) { conc_slot = srv_conc_slots + i; conc_slot->reserved = FALSE; conc_slot->event = os_event_create(NULL); ut_a(conc_slot->event); }
/* Initialize some INFORMATION SCHEMA internal structures */ trx_i_s_cache_init(trx_i_s_cache);}
/*************************************************************************
Frees the OS fast mutex created in srv_init(). */UNIV_INTERNvoidsrv_free(void)/*==========*/{ os_fast_mutex_free(&srv_conc_mutex);}
/*************************************************************************
Initializes the synchronization primitives, memory system, and the threadlocal storage. */UNIV_INTERNvoidsrv_general_init(void)/*==================*/{ os_sync_init(); sync_init(); mem_init(srv_mem_pool_size); thr_local_init();}
/*======================= InnoDB Server FIFO queue =======================*/
/* Maximum allowable purge history length. <=0 means 'infinite'. */UNIV_INTERN ulong srv_max_purge_lag = 0;
/*************************************************************************
Puts an OS thread to wait if there are too many concurrent threads(>= srv_thread_concurrency) inside InnoDB. The threads wait in a FIFO queue. */UNIV_INTERNvoidsrv_conc_enter_innodb(/*==================*/ trx_t* trx) /* in: transaction object associated with the
thread */{ ibool has_slept = FALSE; srv_conc_slot_t* slot = NULL; ulint i;
if (trx->mysql_thd != NULL && thd_is_replication_slave_thread(trx->mysql_thd)) {
UT_WAIT_FOR(srv_conc_n_threads < (lint)srv_thread_concurrency, srv_replication_delay * 1000);
return; }
/* If trx has 'free tickets' to enter the engine left, then use one
such ticket */
if (trx->n_tickets_to_enter_innodb > 0) { trx->n_tickets_to_enter_innodb--;
return; }
os_fast_mutex_lock(&srv_conc_mutex);retry: if (trx->declared_to_be_inside_innodb) { ut_print_timestamp(stderr); fputs(" InnoDB: Error: trying to declare trx" " to enter InnoDB, but\n" "InnoDB: it already is declared.\n", stderr); trx_print(stderr, trx, 0); putc('\n', stderr); os_fast_mutex_unlock(&srv_conc_mutex);
return; }
ut_ad(srv_conc_n_threads >= 0);
if (srv_conc_n_threads < (lint)srv_thread_concurrency) {
srv_conc_n_threads++; trx->declared_to_be_inside_innodb = TRUE; trx->n_tickets_to_enter_innodb = SRV_FREE_TICKETS_TO_ENTER;
os_fast_mutex_unlock(&srv_conc_mutex);
return; }
/* If the transaction is not holding resources, let it sleep
for SRV_THREAD_SLEEP_DELAY microseconds, and try again then */
if (!has_slept && !trx->has_search_latch && NULL == UT_LIST_GET_FIRST(trx->trx_locks)) {
has_slept = TRUE; /* We let it sleep only once to avoid
starvation */
srv_conc_n_waiting_threads++;
os_fast_mutex_unlock(&srv_conc_mutex);
trx->op_info = "sleeping before joining InnoDB queue";
/* Peter Zaitsev suggested that we take the sleep away
altogether. But the sleep may be good in pathological situations of lots of thread switches. Simply put some threads aside for a while to reduce the number of thread switches. */ if (SRV_THREAD_SLEEP_DELAY > 0) { os_thread_sleep(SRV_THREAD_SLEEP_DELAY); }
trx->op_info = "";
os_fast_mutex_lock(&srv_conc_mutex);
srv_conc_n_waiting_threads--;
goto retry; }
/* Too many threads inside: put the current thread to a queue */
for (i = 0; i < OS_THREAD_MAX_N; i++) { slot = srv_conc_slots + i;
if (!slot->reserved) {
break; } }
if (i == OS_THREAD_MAX_N) { /* Could not find a free wait slot, we must let the
thread enter */
srv_conc_n_threads++; trx->declared_to_be_inside_innodb = TRUE; trx->n_tickets_to_enter_innodb = 0;
os_fast_mutex_unlock(&srv_conc_mutex);
return; }
/* Release possible search system latch this thread has */ if (trx->has_search_latch) { trx_search_latch_release_if_reserved(trx); }
/* Add to the queue */ slot->reserved = TRUE; slot->wait_ended = FALSE;
UT_LIST_ADD_LAST(srv_conc_queue, srv_conc_queue, slot);
os_event_reset(slot->event);
srv_conc_n_waiting_threads++;
os_fast_mutex_unlock(&srv_conc_mutex);
/* Go to wait for the event; when a thread leaves InnoDB it will
release this thread */
trx->op_info = "waiting in InnoDB queue";
os_event_wait(slot->event);
trx->op_info = "";
os_fast_mutex_lock(&srv_conc_mutex);
srv_conc_n_waiting_threads--;
/* NOTE that the thread which released this thread already
incremented the thread counter on behalf of this thread */
slot->reserved = FALSE;
UT_LIST_REMOVE(srv_conc_queue, srv_conc_queue, slot);
trx->declared_to_be_inside_innodb = TRUE; trx->n_tickets_to_enter_innodb = SRV_FREE_TICKETS_TO_ENTER;
os_fast_mutex_unlock(&srv_conc_mutex);}
/*************************************************************************
This lets a thread enter InnoDB regardless of the number of threads insideInnoDB. This must be called when a thread ends a lock wait. */UNIV_INTERNvoidsrv_conc_force_enter_innodb(/*========================*/ trx_t* trx) /* in: transaction object associated with the
thread */{ if (UNIV_LIKELY(!srv_thread_concurrency)) {
return; }
ut_ad(srv_conc_n_threads >= 0);
os_fast_mutex_lock(&srv_conc_mutex);
srv_conc_n_threads++; trx->declared_to_be_inside_innodb = TRUE; trx->n_tickets_to_enter_innodb = 1;
os_fast_mutex_unlock(&srv_conc_mutex);}
/*************************************************************************
This must be called when a thread exits InnoDB in a lock wait or at theend of an SQL statement. */UNIV_INTERNvoidsrv_conc_force_exit_innodb(/*=======================*/ trx_t* trx) /* in: transaction object associated with the
thread */{ srv_conc_slot_t* slot = NULL;
if (trx->mysql_thd != NULL && thd_is_replication_slave_thread(trx->mysql_thd)) {
return; }
if (trx->declared_to_be_inside_innodb == FALSE) {
return; }
os_fast_mutex_lock(&srv_conc_mutex);
ut_ad(srv_conc_n_threads > 0); srv_conc_n_threads--; trx->declared_to_be_inside_innodb = FALSE; trx->n_tickets_to_enter_innodb = 0;
if (srv_conc_n_threads < (lint)srv_thread_concurrency) { /* Look for a slot where a thread is waiting and no other
thread has yet released the thread */
slot = UT_LIST_GET_FIRST(srv_conc_queue);
while (slot && slot->wait_ended == TRUE) { slot = UT_LIST_GET_NEXT(srv_conc_queue, slot); }
if (slot != NULL) { slot->wait_ended = TRUE;
/* We increment the count on behalf of the released
thread */
srv_conc_n_threads++; } }
os_fast_mutex_unlock(&srv_conc_mutex);
if (slot != NULL) { os_event_set(slot->event); }}
/*************************************************************************
This must be called when a thread exits InnoDB. */UNIV_INTERNvoidsrv_conc_exit_innodb(/*=================*/ trx_t* trx) /* in: transaction object associated with the
thread */{ if (trx->n_tickets_to_enter_innodb > 0) { /* We will pretend the thread is still inside InnoDB though it
now leaves the InnoDB engine. In this way we save a lot of semaphore operations. srv_conc_force_exit_innodb is used to declare the thread definitely outside InnoDB. It should be called when there is a lock wait or an SQL statement ends. */
return; }
srv_conc_force_exit_innodb(trx);}
/*========================================================================*/
/*************************************************************************
Normalizes init parameter values to use units we use inside InnoDB. */staticulintsrv_normalize_init_values(void)/*===========================*/ /* out: DB_SUCCESS or error code */{ ulint n; ulint i;
n = srv_n_data_files;
for (i = 0; i < n; i++) { srv_data_file_sizes[i] = srv_data_file_sizes[i] * ((1024 * 1024) / UNIV_PAGE_SIZE); }
srv_last_file_size_max = srv_last_file_size_max * ((1024 * 1024) / UNIV_PAGE_SIZE);
srv_log_file_size = srv_log_file_size / UNIV_PAGE_SIZE;
srv_log_buffer_size = srv_log_buffer_size / UNIV_PAGE_SIZE;
srv_lock_table_size = 5 * (srv_buf_pool_size / UNIV_PAGE_SIZE);
return(DB_SUCCESS);}
/*************************************************************************
Boots the InnoDB server. */UNIV_INTERNulintsrv_boot(void)/*==========*/ /* out: DB_SUCCESS or error code */{ ulint err;
/* Transform the init parameter values given by MySQL to
use units we use inside InnoDB: */
err = srv_normalize_init_values();
if (err != DB_SUCCESS) { return(err); }
/* Initialize synchronization primitives, memory management, and thread
local storage */
srv_general_init();
/* Initialize this module */
srv_init();
return(DB_SUCCESS);}
#ifndef UNIV_HOTBACKUP
/*************************************************************************
Reserves a slot in the thread table for the current MySQL OS thread.NOTE! The kernel mutex has to be reserved by the caller! */staticsrv_slot_t*srv_table_reserve_slot_for_mysql(void)/*==================================*/ /* out: reserved slot */{ srv_slot_t* slot; ulint i;
ut_ad(mutex_own(&kernel_mutex));
i = 0; slot = srv_mysql_table + i;
while (slot->in_use) { i++;
if (i >= OS_THREAD_MAX_N) {
ut_print_timestamp(stderr);
fprintf(stderr, " InnoDB: There appear to be %lu MySQL" " threads currently waiting\n" "InnoDB: inside InnoDB, which is the" " upper limit. Cannot continue operation.\n" "InnoDB: We intentionally generate" " a seg fault to print a stack trace\n" "InnoDB: on Linux. But first we print" " a list of waiting threads.\n", (ulong) i);
for (i = 0; i < OS_THREAD_MAX_N; i++) {
slot = srv_mysql_table + i;
fprintf(stderr, "Slot %lu: thread id %lu, type %lu," " in use %lu, susp %lu, time %lu\n", (ulong) i, (ulong) os_thread_pf(slot->id), (ulong) slot->type, (ulong) slot->in_use, (ulong) slot->suspended, (ulong) difftime(ut_time(), slot->suspend_time)); }
ut_error; }
slot = srv_mysql_table + i; }
ut_a(slot->in_use == FALSE);
slot->in_use = TRUE; slot->id = os_thread_get_curr_id(); slot->handle = os_thread_get_curr();
return(slot);}#endif /* !UNIV_HOTBACKUP */
/*******************************************************************
Puts a MySQL OS thread to wait for a lock to be released. If an erroroccurs during the wait trx->error_state associated with thr is!= DB_SUCCESS when we return. DB_LOCK_WAIT_TIMEOUT and DB_DEADLOCKare possible errors. DB_DEADLOCK is returned if selective deadlockresolution chose this transaction as a victim. */UNIV_INTERNvoidsrv_suspend_mysql_thread(/*=====================*/ que_thr_t* thr) /* in: query thread associated with the MySQL
OS thread */{#ifndef UNIV_HOTBACKUP
srv_slot_t* slot; os_event_t event; double wait_time; trx_t* trx; ulint had_dict_lock; ibool was_declared_inside_innodb = FALSE; ib_int64_t start_time = 0; ib_int64_t finish_time; ulint diff_time; ulint sec; ulint ms; ulong lock_wait_timeout;
ut_ad(!mutex_own(&kernel_mutex));
trx = thr_get_trx(thr);
os_event_set(srv_lock_timeout_thread_event);
mutex_enter(&kernel_mutex);
trx->error_state = DB_SUCCESS;
if (thr->state == QUE_THR_RUNNING) {
ut_ad(thr->is_active == TRUE);
/* The lock has already been released or this transaction
was chosen as a deadlock victim: no need to suspend */
if (trx->was_chosen_as_deadlock_victim) {
trx->error_state = DB_DEADLOCK; trx->was_chosen_as_deadlock_victim = FALSE; }
mutex_exit(&kernel_mutex);
return; }
ut_ad(thr->is_active == FALSE);
slot = srv_table_reserve_slot_for_mysql();
event = slot->event;
slot->thr = thr;
os_event_reset(event);
slot->suspend_time = ut_time();
if (thr->lock_state == QUE_THR_LOCK_ROW) { srv_n_lock_wait_count++; srv_n_lock_wait_current_count++;
if (ut_usectime(&sec, &ms) == -1) { start_time = -1; } else { start_time = (ib_int64_t) sec * 1000000 + ms; } } /* Wake the lock timeout monitor thread, if it is suspended */
os_event_set(srv_lock_timeout_thread_event);
mutex_exit(&kernel_mutex);
if (trx->declared_to_be_inside_innodb) {
was_declared_inside_innodb = TRUE;
/* We must declare this OS thread to exit InnoDB, since a
possible other thread holding a lock which this thread waits for must be allowed to enter, sooner or later */
srv_conc_force_exit_innodb(trx); }
had_dict_lock = trx->dict_operation_lock_mode;
switch (had_dict_lock) { case RW_S_LATCH: /* Release foreign key check latch */ row_mysql_unfreeze_data_dictionary(trx); break; case RW_X_LATCH: /* Release fast index creation latch */ row_mysql_unlock_data_dictionary(trx); break; }
ut_a(trx->dict_operation_lock_mode == 0);
/* Suspend this thread and wait for the event. */
os_event_wait(event);
/* After resuming, reacquire the data dictionary latch if
necessary. */
switch (had_dict_lock) { case RW_S_LATCH: row_mysql_freeze_data_dictionary(trx); break; case RW_X_LATCH: row_mysql_lock_data_dictionary(trx); break; }
if (was_declared_inside_innodb) {
/* Return back inside InnoDB */
srv_conc_force_enter_innodb(trx); }
mutex_enter(&kernel_mutex);
/* Release the slot for others to use */
slot->in_use = FALSE;
wait_time = ut_difftime(ut_time(), slot->suspend_time);
if (thr->lock_state == QUE_THR_LOCK_ROW) { if (ut_usectime(&sec, &ms) == -1) { finish_time = -1; } else { finish_time = (ib_int64_t) sec * 1000000 + ms; }
diff_time = (ulint) (finish_time - start_time);
srv_n_lock_wait_current_count--; srv_n_lock_wait_time = srv_n_lock_wait_time + diff_time; if (diff_time > srv_n_lock_max_wait_time && /* only update the variable if we successfully
retrieved the start and finish times. See Bug#36819. */ start_time != -1 && finish_time != -1) { srv_n_lock_max_wait_time = diff_time; } }
if (trx->was_chosen_as_deadlock_victim) {
trx->error_state = DB_DEADLOCK; trx->was_chosen_as_deadlock_victim = FALSE; }
mutex_exit(&kernel_mutex);
/* InnoDB system transactions (such as the purge, and
incomplete transactions that are being rolled back after crash recovery) will use the global value of innodb_lock_wait_timeout, because trx->mysql_thd == NULL. */ lock_wait_timeout = thd_lock_wait_timeout(trx->mysql_thd);
if (lock_wait_timeout < 100000000 && wait_time > (double) lock_wait_timeout) {
trx->error_state = DB_LOCK_WAIT_TIMEOUT; }#else /* UNIV_HOTBACKUP */
/* This function depends on MySQL code that is not included in
InnoDB Hot Backup builds. Besides, this function should never be called in InnoDB Hot Backup. */ ut_error;#endif /* UNIV_HOTBACKUP */
}
/************************************************************************
Releases a MySQL OS thread waiting for a lock to be released, if thethread is already suspended. */UNIV_INTERNvoidsrv_release_mysql_thread_if_suspended(/*==================================*/ que_thr_t* thr) /* in: query thread associated with the
MySQL OS thread */{#ifndef UNIV_HOTBACKUP
srv_slot_t* slot; ulint i;
ut_ad(mutex_own(&kernel_mutex));
for (i = 0; i < OS_THREAD_MAX_N; i++) {
slot = srv_mysql_table + i;
if (slot->in_use && slot->thr == thr) { /* Found */
os_event_set(slot->event);
return; } }
/* not found */#else /* UNIV_HOTBACKUP */
/* This function depends on MySQL code that is not included in
InnoDB Hot Backup builds. Besides, this function should never be called in InnoDB Hot Backup. */ ut_error;#endif /* UNIV_HOTBACKUP */
}
#ifndef UNIV_HOTBACKUP
/**********************************************************************
Refreshes the values used to calculate per-second averages. */staticvoidsrv_refresh_innodb_monitor_stats(void)/*==================================*/{ mutex_enter(&srv_innodb_monitor_mutex);
srv_last_monitor_time = time(NULL);
os_aio_refresh_stats();
btr_cur_n_sea_old = btr_cur_n_sea; btr_cur_n_non_sea_old = btr_cur_n_non_sea;
log_refresh_stats();
buf_refresh_io_stats();
srv_n_rows_inserted_old = srv_n_rows_inserted; srv_n_rows_updated_old = srv_n_rows_updated; srv_n_rows_deleted_old = srv_n_rows_deleted; srv_n_rows_read_old = srv_n_rows_read;
mutex_exit(&srv_innodb_monitor_mutex);}
/**********************************************************************
Outputs to a file the output of the InnoDB Monitor. */UNIV_INTERNvoidsrv_printf_innodb_monitor(/*======================*/ FILE* file, /* in: output stream */ ulint* trx_start, /* out: file position of the start of
the list of active transactions */ ulint* trx_end) /* out: file position of the end of
the list of active transactions */{ double time_elapsed; time_t current_time; ulint n_reserved;
mutex_enter(&srv_innodb_monitor_mutex);
current_time = time(NULL);
/* We add 0.001 seconds to time_elapsed to prevent division
by zero if two users happen to call SHOW INNODB STATUS at the same time */
time_elapsed = difftime(current_time, srv_last_monitor_time) + 0.001;
srv_last_monitor_time = time(NULL);
fputs("\n=====================================\n", file);
ut_print_timestamp(file); fprintf(file, " INNODB MONITOR OUTPUT\n" "=====================================\n" "Per second averages calculated from the last %lu seconds\n", (ulong)time_elapsed);
fputs("----------\n" "SEMAPHORES\n" "----------\n", file); sync_print(file);
/* Conceptually, srv_innodb_monitor_mutex has a very high latching
order level in sync0sync.h, while dict_foreign_err_mutex has a very low level 135. Therefore we can reserve the latter mutex here without a danger of a deadlock of threads. */
mutex_enter(&dict_foreign_err_mutex);
if (ftell(dict_foreign_err_file) != 0L) { fputs("------------------------\n" "LATEST FOREIGN KEY ERROR\n" "------------------------\n", file); ut_copy_file(file, dict_foreign_err_file); }
mutex_exit(&dict_foreign_err_mutex);
lock_print_info_summary(file); if (trx_start) { long t = ftell(file); if (t < 0) { *trx_start = ULINT_UNDEFINED; } else { *trx_start = (ulint) t; } } lock_print_info_all_transactions(file); if (trx_end) { long t = ftell(file); if (t < 0) { *trx_end = ULINT_UNDEFINED; } else { *trx_end = (ulint) t; } } fputs("--------\n" "FILE I/O\n" "--------\n", file); os_aio_print(file);
fputs("-------------------------------------\n" "INSERT BUFFER AND ADAPTIVE HASH INDEX\n" "-------------------------------------\n", file); ibuf_print(file);
ha_print_info(file, btr_search_sys->hash_index);
fprintf(file, "%.2f hash searches/s, %.2f non-hash searches/s\n", (btr_cur_n_sea - btr_cur_n_sea_old) / time_elapsed, (btr_cur_n_non_sea - btr_cur_n_non_sea_old) / time_elapsed); btr_cur_n_sea_old = btr_cur_n_sea; btr_cur_n_non_sea_old = btr_cur_n_non_sea;
fputs("---\n" "LOG\n" "---\n", file); log_print(file);
fputs("----------------------\n" "BUFFER POOL AND MEMORY\n" "----------------------\n", file); fprintf(file, "Total memory allocated " ULINTPF "; in additional pool allocated " ULINTPF "\n", ut_total_allocated_memory, mem_pool_get_reserved(mem_comm_pool)); fprintf(file, "Dictionary memory allocated " ULINTPF "\n", dict_sys->size);
buf_print_io(file);
fputs("--------------\n" "ROW OPERATIONS\n" "--------------\n", file); fprintf(file, "%ld queries inside InnoDB, %lu queries in queue\n", (long) srv_conc_n_threads, (ulong) srv_conc_n_waiting_threads);
fprintf(file, "%lu read views open inside InnoDB\n", UT_LIST_GET_LEN(trx_sys->view_list));
n_reserved = fil_space_get_n_reserved_extents(0); if (n_reserved > 0) { fprintf(file, "%lu tablespace extents now reserved for" " B-tree split operations\n", (ulong) n_reserved); }
#ifdef UNIV_LINUX
fprintf(file, "Main thread process no. %lu, id %lu, state: %s\n", (ulong) srv_main_thread_process_no, (ulong) srv_main_thread_id, srv_main_thread_op_info);#else
fprintf(file, "Main thread id %lu, state: %s\n", (ulong) srv_main_thread_id, srv_main_thread_op_info);#endif
fprintf(file, "Number of rows inserted " ULINTPF ", updated " ULINTPF ", deleted " ULINTPF ", read " ULINTPF "\n", srv_n_rows_inserted, srv_n_rows_updated, srv_n_rows_deleted, srv_n_rows_read); fprintf(file, "%.2f inserts/s, %.2f updates/s," " %.2f deletes/s, %.2f reads/s\n", (srv_n_rows_inserted - srv_n_rows_inserted_old) / time_elapsed, (srv_n_rows_updated - srv_n_rows_updated_old) / time_elapsed, (srv_n_rows_deleted - srv_n_rows_deleted_old) / time_elapsed, (srv_n_rows_read - srv_n_rows_read_old) / time_elapsed);
srv_n_rows_inserted_old = srv_n_rows_inserted; srv_n_rows_updated_old = srv_n_rows_updated; srv_n_rows_deleted_old = srv_n_rows_deleted; srv_n_rows_read_old = srv_n_rows_read;
fputs("----------------------------\n" "END OF INNODB MONITOR OUTPUT\n" "============================\n", file); mutex_exit(&srv_innodb_monitor_mutex); fflush(file);}
/**********************************************************************
Function to pass InnoDB status variables to MySQL */UNIV_INTERNvoidsrv_export_innodb_status(void){ mutex_enter(&srv_innodb_monitor_mutex);
export_vars.innodb_data_pending_reads = os_n_pending_reads; export_vars.innodb_data_pending_writes = os_n_pending_writes; export_vars.innodb_data_pending_fsyncs = fil_n_pending_log_flushes + fil_n_pending_tablespace_flushes; export_vars.innodb_data_fsyncs = os_n_fsyncs; export_vars.innodb_data_read = srv_data_read; export_vars.innodb_data_reads = os_n_file_reads; export_vars.innodb_data_writes = os_n_file_writes; export_vars.innodb_data_written = srv_data_written; export_vars.innodb_buffer_pool_read_requests = buf_pool->n_page_gets; export_vars.innodb_buffer_pool_write_requests = srv_buf_pool_write_requests; export_vars.innodb_buffer_pool_wait_free = srv_buf_pool_wait_free; export_vars.innodb_buffer_pool_pages_flushed = srv_buf_pool_flushed; export_vars.innodb_buffer_pool_reads = srv_buf_pool_reads; export_vars.innodb_buffer_pool_read_ahead_rnd = srv_read_ahead_rnd; export_vars.innodb_buffer_pool_read_ahead_seq = srv_read_ahead_seq; export_vars.innodb_buffer_pool_pages_data = UT_LIST_GET_LEN(buf_pool->LRU); export_vars.innodb_buffer_pool_pages_dirty = UT_LIST_GET_LEN(buf_pool->flush_list); export_vars.innodb_buffer_pool_pages_free = UT_LIST_GET_LEN(buf_pool->free);#ifdef UNIV_DEBUG
export_vars.innodb_buffer_pool_pages_latched = buf_get_latched_pages_number();#endif /* UNIV_DEBUG */
export_vars.innodb_buffer_pool_pages_total = buf_pool->curr_size;
export_vars.innodb_buffer_pool_pages_misc = buf_pool->curr_size - UT_LIST_GET_LEN(buf_pool->LRU) - UT_LIST_GET_LEN(buf_pool->free);#ifdef HAVE_GCC_ATOMIC_BUILTINS
export_vars.innodb_have_atomic_builtins = 1;#else
export_vars.innodb_have_atomic_builtins = 0;#endif
export_vars.innodb_page_size = UNIV_PAGE_SIZE; export_vars.innodb_log_waits = srv_log_waits; export_vars.innodb_os_log_written = srv_os_log_written; export_vars.innodb_os_log_fsyncs = fil_n_log_flushes; export_vars.innodb_os_log_pending_fsyncs = fil_n_pending_log_flushes; export_vars.innodb_os_log_pending_writes = srv_os_log_pending_writes; export_vars.innodb_log_write_requests = srv_log_write_requests; export_vars.innodb_log_writes = srv_log_writes; export_vars.innodb_dblwr_pages_written = srv_dblwr_pages_written; export_vars.innodb_dblwr_writes = srv_dblwr_writes; export_vars.innodb_pages_created = buf_pool->n_pages_created; export_vars.innodb_pages_read = buf_pool->n_pages_read; export_vars.innodb_pages_written = buf_pool->n_pages_written; export_vars.innodb_row_lock_waits = srv_n_lock_wait_count; export_vars.innodb_row_lock_current_waits = srv_n_lock_wait_current_count; export_vars.innodb_row_lock_time = srv_n_lock_wait_time / 1000; if (srv_n_lock_wait_count > 0) { export_vars.innodb_row_lock_time_avg = (ulint) (srv_n_lock_wait_time / 1000 / srv_n_lock_wait_count); } else { export_vars.innodb_row_lock_time_avg = 0; } export_vars.innodb_row_lock_time_max = srv_n_lock_max_wait_time / 1000; export_vars.innodb_rows_read = srv_n_rows_read; export_vars.innodb_rows_inserted = srv_n_rows_inserted; export_vars.innodb_rows_updated = srv_n_rows_updated; export_vars.innodb_rows_deleted = srv_n_rows_deleted;
mutex_exit(&srv_innodb_monitor_mutex);}
/*************************************************************************
A thread which wakes up threads whose lock wait may have lasted too long.This also prints the info output by various InnoDB monitors. */UNIV_INTERNos_thread_ret_tsrv_lock_timeout_and_monitor_thread(/*================================*/ /* out: a dummy parameter */ void* arg __attribute__((unused))) /* in: a dummy parameter required by
os_thread_create */{ srv_slot_t* slot; double time_elapsed; time_t current_time; time_t last_table_monitor_time; time_t last_tablespace_monitor_time; time_t last_monitor_time; ibool some_waits; double wait_time; ulint i;
#ifdef UNIV_DEBUG_THREAD_CREATION
fprintf(stderr, "Lock timeout thread starts, id %lu\n", os_thread_pf(os_thread_get_curr_id()));#endif
UT_NOT_USED(arg); srv_last_monitor_time = time(NULL); last_table_monitor_time = time(NULL); last_tablespace_monitor_time = time(NULL); last_monitor_time = time(NULL);loop: srv_lock_timeout_and_monitor_active = TRUE;
/* When someone is waiting for a lock, we wake up every second
and check if a timeout has passed for a lock wait */
os_thread_sleep(1000000);
current_time = time(NULL);
time_elapsed = difftime(current_time, last_monitor_time);
if (time_elapsed > 15) { last_monitor_time = time(NULL);
if (srv_print_innodb_monitor) { srv_printf_innodb_monitor(stderr, NULL, NULL); }
if (srv_innodb_status) { mutex_enter(&srv_monitor_file_mutex); rewind(srv_monitor_file); srv_printf_innodb_monitor(srv_monitor_file, NULL, NULL); os_file_set_eof(srv_monitor_file); mutex_exit(&srv_monitor_file_mutex); }
if (srv_print_innodb_tablespace_monitor && difftime(current_time, last_tablespace_monitor_time) > 60) { last_tablespace_monitor_time = time(NULL);
fputs("========================" "========================\n", stderr);
ut_print_timestamp(stderr);
fputs(" INNODB TABLESPACE MONITOR OUTPUT\n" "========================" "========================\n", stderr);
fsp_print(0); fputs("Validating tablespace\n", stderr); fsp_validate(0); fputs("Validation ok\n" "---------------------------------------\n" "END OF INNODB TABLESPACE MONITOR OUTPUT\n" "=======================================\n", stderr); }
if (srv_print_innodb_table_monitor && difftime(current_time, last_table_monitor_time) > 60) {
last_table_monitor_time = time(NULL);
fputs("===========================================\n", stderr);
ut_print_timestamp(stderr);
fputs(" INNODB TABLE MONITOR OUTPUT\n" "===========================================\n", stderr); dict_print();
fputs("-----------------------------------\n" "END OF INNODB TABLE MONITOR OUTPUT\n" "==================================\n", stderr); } }
mutex_enter(&kernel_mutex);
some_waits = FALSE;
/* Check of all slots if a thread is waiting there, and if it
has exceeded the time limit */
for (i = 0; i < OS_THREAD_MAX_N; i++) {
slot = srv_mysql_table + i;
if (slot->in_use) { trx_t* trx; ulong lock_wait_timeout;
some_waits = TRUE;
wait_time = ut_difftime(ut_time(), slot->suspend_time);
trx = thr_get_trx(slot->thr); lock_wait_timeout = thd_lock_wait_timeout( trx->mysql_thd);
if (lock_wait_timeout < 100000000 && (wait_time > (double) lock_wait_timeout || wait_time < 0)) {
/* Timeout exceeded or a wrap-around in system
time counter: cancel the lock request queued by the transaction and release possible other transactions waiting behind; it is possible that the lock has already been granted: in that case do nothing */
if (trx->wait_lock) { lock_cancel_waiting_and_release( trx->wait_lock); } } } }
os_event_reset(srv_lock_timeout_thread_event);
mutex_exit(&kernel_mutex);
if (srv_shutdown_state >= SRV_SHUTDOWN_CLEANUP) { goto exit_func; }
if (some_waits || srv_print_innodb_monitor || srv_print_innodb_lock_monitor || srv_print_innodb_tablespace_monitor || srv_print_innodb_table_monitor) { goto loop; }
/* No one was waiting for a lock and no monitor was active:
suspend this thread */
srv_lock_timeout_and_monitor_active = FALSE;
#if 0
/* The following synchronisation is disabled, since
the InnoDB monitor output is to be updated every 15 seconds. */ os_event_wait(srv_lock_timeout_thread_event);#endif
goto loop;
exit_func: srv_lock_timeout_and_monitor_active = FALSE;
/* We count the number of threads in os_thread_exit(). A created
thread should always use that to exit and not use return() to exit. */
os_thread_exit(NULL);
OS_THREAD_DUMMY_RETURN;}
/*************************************************************************
A thread which prints warnings about semaphore waits which have lastedtoo long. These can be used to track bugs which cause hangs. */UNIV_INTERNos_thread_ret_tsrv_error_monitor_thread(/*=====================*/ /* out: a dummy parameter */ void* arg __attribute__((unused))) /* in: a dummy parameter required by
os_thread_create */{ /* number of successive fatal timeouts observed */ ulint fatal_cnt = 0; ib_uint64_t old_lsn; ib_uint64_t new_lsn;
old_lsn = srv_start_lsn;
#ifdef UNIV_DEBUG_THREAD_CREATION
fprintf(stderr, "Error monitor thread starts, id %lu\n", os_thread_pf(os_thread_get_curr_id()));#endif
loop: srv_error_monitor_active = TRUE;
/* Try to track a strange bug reported by Harald Fuchs and others,
where the lsn seems to decrease at times */
new_lsn = log_get_lsn();
if (new_lsn < old_lsn) { ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: Error: old log sequence number %llu" " was greater\n" "InnoDB: than the new log sequence number %llu!\n" "InnoDB: Please submit a bug report" " to http://bugs.mysql.com\n", old_lsn, new_lsn); }
old_lsn = new_lsn;
if (difftime(time(NULL), srv_last_monitor_time) > 60) { /* We referesh InnoDB Monitor values so that averages are
printed from at most 60 last seconds */
srv_refresh_innodb_monitor_stats(); }
/* Update the statistics collected for deciding LRU
eviction policy. */ buf_LRU_stat_update();
/* In case mutex_exit is not a memory barrier, it is
theoretically possible some threads are left waiting though the semaphore is already released. Wake up those threads: */ sync_arr_wake_threads_if_sema_free();
if (sync_array_print_long_waits()) { fatal_cnt++; if (fatal_cnt > 10) {
fprintf(stderr, "InnoDB: Error: semaphore wait has lasted" " > %lu seconds\n" "InnoDB: We intentionally crash the server," " because it appears to be hung.\n", (ulong) srv_fatal_semaphore_wait_threshold);
ut_error; } } else { fatal_cnt = 0; }
/* Flush stderr so that a database user gets the output
to possible MySQL error file */
fflush(stderr);
os_thread_sleep(1000000);
if (srv_shutdown_state < SRV_SHUTDOWN_CLEANUP) {
goto loop; }
srv_error_monitor_active = FALSE;
/* We count the number of threads in os_thread_exit(). A created
thread should always use that to exit and not use return() to exit. */
os_thread_exit(NULL);
OS_THREAD_DUMMY_RETURN;}
/***********************************************************************
Tells the InnoDB server that there has been activity in the databaseand wakes up the master thread if it is suspended (not sleeping). Usedin the MySQL interface. Note that there is a small chance that the masterthread stays suspended (we do not protect our operation with the kernelmutex, for performace reasons). */UNIV_INTERNvoidsrv_active_wake_master_thread(void)/*===============================*/{ srv_activity_count++;
if (srv_n_threads_active[SRV_MASTER] == 0) {
mutex_enter(&kernel_mutex);
srv_release_threads(SRV_MASTER, 1);
mutex_exit(&kernel_mutex); }}
/***********************************************************************
Wakes up the master thread if it is suspended or being suspended. */UNIV_INTERNvoidsrv_wake_master_thread(void)/*========================*/{ srv_activity_count++;
mutex_enter(&kernel_mutex);
srv_release_threads(SRV_MASTER, 1);
mutex_exit(&kernel_mutex);}
/*************************************************************************
The master thread controlling the server. */UNIV_INTERNos_thread_ret_tsrv_master_thread(/*==============*/ /* out: a dummy parameter */ void* arg __attribute__((unused))) /* in: a dummy parameter required by
os_thread_create */{ os_event_t event; time_t last_flush_time; time_t current_time; ulint old_activity_count; ulint n_pages_purged = 0; ulint n_bytes_merged; ulint n_pages_flushed; ulint n_bytes_archived; ulint n_tables_to_drop; ulint n_ios; ulint n_ios_old; ulint n_ios_very_old; ulint n_pend_ios; ibool skip_sleep = FALSE; ulint i;
#ifdef UNIV_DEBUG_THREAD_CREATION
fprintf(stderr, "Master thread starts, id %lu\n", os_thread_pf(os_thread_get_curr_id()));#endif
srv_main_thread_process_no = os_proc_get_number(); srv_main_thread_id = os_thread_pf(os_thread_get_curr_id());
srv_table_reserve_slot(SRV_MASTER);
mutex_enter(&kernel_mutex);
srv_n_threads_active[SRV_MASTER]++;
mutex_exit(&kernel_mutex);
loop: /*****************************************************************/ /* ---- When there is database activity by users, we cycle in this
loop */
srv_main_thread_op_info = "reserving kernel mutex";
n_ios_very_old = log_sys->n_log_ios + buf_pool->n_pages_read + buf_pool->n_pages_written; mutex_enter(&kernel_mutex);
/* Store the user activity counter at the start of this loop */ old_activity_count = srv_activity_count;
mutex_exit(&kernel_mutex);
if (srv_force_recovery >= SRV_FORCE_NO_BACKGROUND) {
goto suspend_thread; }
/* ---- We run the following loop approximately once per second
when there is database activity */
skip_sleep = FALSE;
for (i = 0; i < 10; i++) { n_ios_old = log_sys->n_log_ios + buf_pool->n_pages_read + buf_pool->n_pages_written; srv_main_thread_op_info = "sleeping";
if (!skip_sleep) {
os_thread_sleep(1000000); }
skip_sleep = FALSE;
/* ALTER TABLE in MySQL requires on Unix that the table handler
can drop tables lazily after there no longer are SELECT queries to them. */
srv_main_thread_op_info = "doing background drop tables";
row_drop_tables_for_mysql_in_background();
srv_main_thread_op_info = "";
if (srv_fast_shutdown && srv_shutdown_state > 0) {
goto background_loop; }
/* We flush the log once in a second even if no commit
is issued or the we have specified in my.cnf no flush at transaction commit */
srv_main_thread_op_info = "flushing log"; log_buffer_flush_to_disk();
srv_main_thread_op_info = "making checkpoint"; log_free_check();
/* If there were less than 5 i/os during the
one second sleep, we assume that there is free disk i/o capacity available, and it makes sense to do an insert buffer merge. */
n_pend_ios = buf_get_n_pending_ios() + log_sys->n_pending_writes; n_ios = log_sys->n_log_ios + buf_pool->n_pages_read + buf_pool->n_pages_written; if (n_pend_ios < 3 && (n_ios - n_ios_old < 5)) { srv_main_thread_op_info = "doing insert buffer merge"; ibuf_contract_for_n_pages( TRUE, srv_insert_buffer_batch_size / 4);
srv_main_thread_op_info = "flushing log";
log_buffer_flush_to_disk(); }
if (UNIV_UNLIKELY(buf_get_modified_ratio_pct() > srv_max_buf_pool_modified_pct)) {
/* Try to keep the number of modified pages in the
buffer pool under the limit wished by the user */
n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, 100, IB_ULONGLONG_MAX);
/* If we had to do the flush, it may have taken
even more than 1 second, and also, there may be more to flush. Do not sleep 1 second during the next iteration of this loop. */
skip_sleep = TRUE; }
if (srv_activity_count == old_activity_count) {
/* There is no user activity at the moment, go to
the background loop */
goto background_loop; } }
/* ---- We perform the following code approximately once per
10 seconds when there is database activity */
#ifdef MEM_PERIODIC_CHECK
/* Check magic numbers of every allocated mem block once in 10
seconds */ mem_validate_all_blocks();#endif
/* If there were less than 200 i/os during the 10 second period,
we assume that there is free disk i/o capacity available, and it makes sense to flush 100 pages. */
n_pend_ios = buf_get_n_pending_ios() + log_sys->n_pending_writes; n_ios = log_sys->n_log_ios + buf_pool->n_pages_read + buf_pool->n_pages_written; if (n_pend_ios < 3 && (n_ios - n_ios_very_old < 200)) {
srv_main_thread_op_info = "flushing buffer pool pages"; buf_flush_batch(BUF_FLUSH_LIST, 100, IB_ULONGLONG_MAX);
srv_main_thread_op_info = "flushing log"; log_buffer_flush_to_disk(); }
/* We run a batch of insert buffer merge every 10 seconds,
even if the server were active */
srv_main_thread_op_info = "doing insert buffer merge"; ibuf_contract_for_n_pages(TRUE, srv_insert_buffer_batch_size / 4);
srv_main_thread_op_info = "flushing log"; log_buffer_flush_to_disk();
/* We run a full purge every 10 seconds, even if the server
were active */
last_flush_time = time(NULL);
do {
if (srv_fast_shutdown && srv_shutdown_state > 0) {
goto background_loop; }
srv_main_thread_op_info = "purging"; n_pages_purged = trx_purge();
current_time = time(NULL);
if (difftime(current_time, last_flush_time) > 1) { srv_main_thread_op_info = "flushing log";
log_buffer_flush_to_disk(); last_flush_time = current_time; } } while (n_pages_purged);
srv_main_thread_op_info = "flushing buffer pool pages";
/* Flush a few oldest pages to make a new checkpoint younger */
if (buf_get_modified_ratio_pct() > 70) {
/* If there are lots of modified pages in the buffer pool
(> 70 %), we assume we can afford reserving the disk(s) for the time it requires to flush 100 pages */
n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, 100, IB_ULONGLONG_MAX); } else { /* Otherwise, we only flush a small number of pages so that
we do not unnecessarily use much disk i/o capacity from other work */
n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, 10, IB_ULONGLONG_MAX); }
srv_main_thread_op_info = "making checkpoint";
/* Make a new checkpoint about once in 10 seconds */
log_checkpoint(TRUE, FALSE);
srv_main_thread_op_info = "reserving kernel mutex";
mutex_enter(&kernel_mutex);
/* ---- When there is database activity, we jump from here back to
the start of loop */
if (srv_activity_count != old_activity_count) { mutex_exit(&kernel_mutex); goto loop; }
mutex_exit(&kernel_mutex);
/* If the database is quiet, we enter the background loop */
/*****************************************************************/background_loop: /* ---- In this loop we run background operations when the server
is quiet from user activity. Also in the case of a shutdown, we loop here, flushing the buffer pool to the data files. */
/* The server has been quiet for a while: start running background
operations */
srv_main_thread_op_info = "doing background drop tables";
n_tables_to_drop = row_drop_tables_for_mysql_in_background();
if (n_tables_to_drop > 0) { /* Do not monopolize the CPU even if there are tables waiting
in the background drop queue. (It is essentially a bug if MySQL tries to drop a table while there are still open handles to it and we had to put it to the background drop queue.) */
os_thread_sleep(100000); }
srv_main_thread_op_info = "purging";
/* Run a full purge */
last_flush_time = time(NULL);
do { if (srv_fast_shutdown && srv_shutdown_state > 0) {
break; }
srv_main_thread_op_info = "purging"; n_pages_purged = trx_purge();
current_time = time(NULL);
if (difftime(current_time, last_flush_time) > 1) { srv_main_thread_op_info = "flushing log";
log_buffer_flush_to_disk(); last_flush_time = current_time; } } while (n_pages_purged);
srv_main_thread_op_info = "reserving kernel mutex";
mutex_enter(&kernel_mutex); if (srv_activity_count != old_activity_count) { mutex_exit(&kernel_mutex); goto loop; } mutex_exit(&kernel_mutex);
srv_main_thread_op_info = "doing insert buffer merge";
if (srv_fast_shutdown && srv_shutdown_state > 0) { n_bytes_merged = 0; } else { n_bytes_merged = ibuf_contract_for_n_pages( TRUE, srv_insert_buffer_batch_size); }
srv_main_thread_op_info = "reserving kernel mutex";
mutex_enter(&kernel_mutex); if (srv_activity_count != old_activity_count) { mutex_exit(&kernel_mutex); goto loop; } mutex_exit(&kernel_mutex);
flush_loop: srv_main_thread_op_info = "flushing buffer pool pages";
if (srv_fast_shutdown < 2) { n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, 100, IB_ULONGLONG_MAX); } else { /* In the fastest shutdown we do not flush the buffer pool
to data files: we set n_pages_flushed to 0 artificially. */
n_pages_flushed = 0; }
srv_main_thread_op_info = "reserving kernel mutex";
mutex_enter(&kernel_mutex); if (srv_activity_count != old_activity_count) { mutex_exit(&kernel_mutex); goto loop; } mutex_exit(&kernel_mutex);
srv_main_thread_op_info = "waiting for buffer pool flush to end"; buf_flush_wait_batch_end(BUF_FLUSH_LIST);
srv_main_thread_op_info = "flushing log";
log_buffer_flush_to_disk();
srv_main_thread_op_info = "making checkpoint";
log_checkpoint(TRUE, FALSE);
if (buf_get_modified_ratio_pct() > srv_max_buf_pool_modified_pct) {
/* Try to keep the number of modified pages in the
buffer pool under the limit wished by the user */
goto flush_loop; }
srv_main_thread_op_info = "reserving kernel mutex";
mutex_enter(&kernel_mutex); if (srv_activity_count != old_activity_count) { mutex_exit(&kernel_mutex); goto loop; } mutex_exit(&kernel_mutex); /*
srv_main_thread_op_info = "archiving log (if log archive is on)";
log_archive_do(FALSE, &n_bytes_archived); */ n_bytes_archived = 0;
/* Keep looping in the background loop if still work to do */
if (srv_fast_shutdown && srv_shutdown_state > 0) { if (n_tables_to_drop + n_pages_flushed + n_bytes_archived != 0) {
/* If we are doing a fast shutdown (= the default)
we do not do purge or insert buffer merge. But we flush the buffer pool completely to disk. In a 'very fast' shutdown we do not flush the buffer pool to data files: we have set n_pages_flushed to 0 artificially. */
goto background_loop; } } else if (n_tables_to_drop + n_pages_purged + n_bytes_merged + n_pages_flushed + n_bytes_archived != 0) { /* In a 'slow' shutdown we run purge and the insert buffer
merge to completion */
goto background_loop; }
/* There is no work for background operations either: suspend
master thread to wait for more server activity */
suspend_thread: srv_main_thread_op_info = "suspending";
mutex_enter(&kernel_mutex);
if (row_get_background_drop_list_len_low() > 0) { mutex_exit(&kernel_mutex);
goto loop; }
event = srv_suspend_thread();
mutex_exit(&kernel_mutex);
/* DO NOT CHANGE THIS STRING. innobase_start_or_create_for_mysql()
waits for database activity to die down when converting < 4.1.x databases, and relies on this string being exactly as it is. InnoDB manual also mentions this string in several places. */ srv_main_thread_op_info = "waiting for server activity";
os_event_wait(event);
if (srv_shutdown_state == SRV_SHUTDOWN_EXIT_THREADS) { /* This is only extra safety, the thread should exit
already when the event wait ends */
os_thread_exit(NULL); }
/* When there is user activity, InnoDB will set the event and the
main thread goes back to loop. */
goto loop;
OS_THREAD_DUMMY_RETURN; /* Not reached, avoid compiler warning */}#endif /* !UNIV_HOTBACKUP */
|