Commit 247ecb75 authored by Mikael Ronstrom's avatar Mikael Ronstrom

BUG#59013, make partition handler not miss HA_STATUS_NO_LOCK, add...

BUG#59013, make partition handler not miss HA_STATUS_NO_LOCK, add HA_STATUS_VARIABLE_EXTRA to remove InnoDB bottleneck
parent 4f286ed6
...@@ -351,7 +351,7 @@ enum ha_base_keytype { ...@@ -351,7 +351,7 @@ enum ha_base_keytype {
/* /*
update the 'variable' part of the info: update the 'variable' part of the info:
handler::records, deleted, data_file_length, index_file_length, handler::records, deleted, data_file_length, index_file_length,
delete_length, check_time, mean_rec_length check_time, mean_rec_length
*/ */
#define HA_STATUS_VARIABLE 16 #define HA_STATUS_VARIABLE 16
/* /*
...@@ -364,6 +364,11 @@ enum ha_base_keytype { ...@@ -364,6 +364,11 @@ enum ha_base_keytype {
update handler::auto_increment_value update handler::auto_increment_value
*/ */
#define HA_STATUS_AUTO 64 #define HA_STATUS_AUTO 64
/*
Get also delete_length when HA_STATUS_VARIABLE is called. It's ok to set it also
when only HA_STATUS_VARIABLE but it won't be used.
*/
#define HA_STATUS_VARIABLE_EXTRA 128
/* /*
Errorcodes given by handler functions Errorcodes given by handler functions
......
...@@ -5172,6 +5172,8 @@ int ha_partition::handle_ordered_prev(uchar *buf) ...@@ -5172,6 +5172,8 @@ int ha_partition::handle_ordered_prev(uchar *buf)
int ha_partition::info(uint flag) int ha_partition::info(uint flag)
{ {
uint no_lock_flag= flag & HA_STATUS_NO_LOCK;
uint extra_var_flag= flag & HA_STATUS_VARIABLE_EXTRA;
DBUG_ENTER("ha_partition::info"); DBUG_ENTER("ha_partition::info");
if (flag & HA_STATUS_AUTO) if (flag & HA_STATUS_AUTO)
...@@ -5203,7 +5205,7 @@ int ha_partition::info(uint flag) ...@@ -5203,7 +5205,7 @@ int ha_partition::info(uint flag)
do do
{ {
file= *file_array; file= *file_array;
file->info(HA_STATUS_AUTO); file->info(HA_STATUS_AUTO | no_lock_flag);
set_if_bigger(auto_increment_value, set_if_bigger(auto_increment_value,
file->stats.auto_increment_value); file->stats.auto_increment_value);
} while (*(++file_array)); } while (*(++file_array));
...@@ -5257,7 +5259,7 @@ int ha_partition::info(uint flag) ...@@ -5257,7 +5259,7 @@ int ha_partition::info(uint flag)
if (bitmap_is_set(&(m_part_info->used_partitions), (file_array - m_file))) if (bitmap_is_set(&(m_part_info->used_partitions), (file_array - m_file)))
{ {
file= *file_array; file= *file_array;
file->info(HA_STATUS_VARIABLE); file->info(HA_STATUS_VARIABLE | no_lock_flag | extra_var_flag);
stats.records+= file->stats.records; stats.records+= file->stats.records;
stats.deleted+= file->stats.deleted; stats.deleted+= file->stats.deleted;
stats.data_file_length+= file->stats.data_file_length; stats.data_file_length+= file->stats.data_file_length;
...@@ -5339,7 +5341,7 @@ int ha_partition::info(uint flag) ...@@ -5339,7 +5341,7 @@ int ha_partition::info(uint flag)
if (!(flag & HA_STATUS_VARIABLE) || if (!(flag & HA_STATUS_VARIABLE) ||
!bitmap_is_set(&(m_part_info->used_partitions), !bitmap_is_set(&(m_part_info->used_partitions),
(file_array - m_file))) (file_array - m_file)))
file->info(HA_STATUS_VARIABLE); file->info(HA_STATUS_VARIABLE | no_lock_flag | extra_var_flag);
if (file->stats.records > max_records) if (file->stats.records > max_records)
{ {
max_records= file->stats.records; max_records= file->stats.records;
...@@ -5349,7 +5351,7 @@ int ha_partition::info(uint flag) ...@@ -5349,7 +5351,7 @@ int ha_partition::info(uint flag)
} while (*(++file_array)); } while (*(++file_array));
file= m_file[handler_instance]; file= m_file[handler_instance];
file->info(HA_STATUS_CONST); file->info(HA_STATUS_CONST | no_lock_flag);
stats.block_size= file->stats.block_size; stats.block_size= file->stats.block_size;
stats.create_time= file->stats.create_time; stats.create_time= file->stats.create_time;
ref_length= m_ref_length; ref_length= m_ref_length;
...@@ -5365,7 +5367,7 @@ int ha_partition::info(uint flag) ...@@ -5365,7 +5367,7 @@ int ha_partition::info(uint flag)
Note: all engines does not support HA_STATUS_ERRKEY, so set errkey. Note: all engines does not support HA_STATUS_ERRKEY, so set errkey.
*/ */
file->errkey= errkey; file->errkey= errkey;
file->info(HA_STATUS_ERRKEY); file->info(HA_STATUS_ERRKEY | no_lock_flag);
errkey= file->errkey; errkey= file->errkey;
} }
if (flag & HA_STATUS_TIME) if (flag & HA_STATUS_TIME)
...@@ -5382,7 +5384,7 @@ int ha_partition::info(uint flag) ...@@ -5382,7 +5384,7 @@ int ha_partition::info(uint flag)
do do
{ {
file= *file_array; file= *file_array;
file->info(HA_STATUS_TIME); file->info(HA_STATUS_TIME | no_lock_flag);
if (file->stats.update_time > stats.update_time) if (file->stats.update_time > stats.update_time)
stats.update_time= file->stats.update_time; stats.update_time= file->stats.update_time;
} while (*(++file_array)); } while (*(++file_array));
...@@ -5396,7 +5398,7 @@ void ha_partition::get_dynamic_partition_info(PARTITION_STATS *stat_info, ...@@ -5396,7 +5398,7 @@ void ha_partition::get_dynamic_partition_info(PARTITION_STATS *stat_info,
{ {
handler *file= m_file[part_id]; handler *file= m_file[part_id];
file->info(HA_STATUS_CONST | HA_STATUS_TIME | HA_STATUS_VARIABLE | file->info(HA_STATUS_CONST | HA_STATUS_TIME | HA_STATUS_VARIABLE |
HA_STATUS_NO_LOCK); HA_STATUS_VARIABLE_EXTRA | HA_STATUS_NO_LOCK);
stat_info->records= file->stats.records; stat_info->records= file->stats.records;
stat_info->mean_rec_length= file->stats.mean_rec_length; stat_info->mean_rec_length= file->stats.mean_rec_length;
......
...@@ -3925,6 +3925,7 @@ static int get_schema_tables_record(THD *thd, TABLE_LIST *tables, ...@@ -3925,6 +3925,7 @@ static int get_schema_tables_record(THD *thd, TABLE_LIST *tables,
/* If info() fails, then there's nothing else to do */ /* If info() fails, then there's nothing else to do */
if ((info_error= file->info(HA_STATUS_VARIABLE | if ((info_error= file->info(HA_STATUS_VARIABLE |
HA_STATUS_TIME | HA_STATUS_TIME |
HA_STATUS_VARIABLE_EXTRA |
HA_STATUS_AUTO)) != 0) HA_STATUS_AUTO)) != 0)
goto err; goto err;
......
...@@ -7849,11 +7849,14 @@ ha_innobase::info_low( ...@@ -7849,11 +7849,14 @@ ha_innobase::info_low(
are asked by MySQL to avoid locking. Another reason to are asked by MySQL to avoid locking. Another reason to
avoid the call is that it uses quite a lot of CPU. avoid the call is that it uses quite a lot of CPU.
See Bug#38185. */ See Bug#38185. */
if (flag & HA_STATUS_NO_LOCK) { if (flag & HA_STATUS_NO_LOCK ||
!(flag & HA_STATUS_VARIABLE_EXTRA)) {
/* We do not update delete_length if no /* We do not update delete_length if no
locking is requested so the "old" value can locking is requested so the "old" value can
remain. delete_length is initialized to 0 in remain. delete_length is initialized to 0 in
the ha_statistics' constructor. */ the ha_statistics' constructor. Also we only
need delete_length to be set when
HA_STATUS_VARIABLE_EXTRA is set */
} else if (UNIV_UNLIKELY } else if (UNIV_UNLIKELY
(srv_force_recovery >= SRV_FORCE_NO_IBUF_MERGE)) { (srv_force_recovery >= SRV_FORCE_NO_IBUF_MERGE)) {
/* Avoid accessing the tablespace if /* Avoid accessing the tablespace if
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment