Commit 2f3f1cd0 authored by Nayuta Yanagisawa's avatar Nayuta Yanagisawa

MDEV-26544 Assertion `part_share->auto_inc_initialized' failed in...

MDEV-26544 Assertion `part_share->auto_inc_initialized' failed in ha_partition::get_auto_increment on INSERT

The partition storage engine ignores return (error) values of
handler::info(). As a result, a query that should be aborted is
not aborted and then the server violates the assertion.
parent 4bc7c03b
......@@ -4353,15 +4353,15 @@ int ha_partition::write_row(uchar * buf)
if (have_auto_increment)
{
if (!table_share->next_number_keypart)
update_next_auto_inc_val();
error= update_auto_increment();
if (unlikely(error= update_next_auto_inc_val()))
goto exit;
/*
If we have failed to set the auto-increment value for this row,
it is highly likely that we will not be able to insert it into
the correct partition. We must check and fail if necessary.
*/
if (unlikely(error))
if (unlikely(error= update_auto_increment()))
goto exit;
/*
......@@ -8301,6 +8301,7 @@ int ha_partition::compare_number_of_records(ha_partition *me,
int ha_partition::info(uint flag)
{
int error;
uint no_lock_flag= flag & HA_STATUS_NO_LOCK;
uint extra_var_flag= flag & HA_STATUS_VARIABLE_EXTRA;
DBUG_ENTER("ha_partition::info");
......@@ -8353,7 +8354,11 @@ int ha_partition::info(uint flag)
break;
}
file= *file_array;
file->info(HA_STATUS_AUTO | no_lock_flag);
if ((error= file->info(HA_STATUS_AUTO | no_lock_flag)))
{
unlock_auto_increment();
DBUG_RETURN(error);
}
set_if_bigger(auto_increment_value,
file->stats.auto_increment_value);
} while (*(++file_array));
......@@ -8409,7 +8414,8 @@ int ha_partition::info(uint flag)
i= bitmap_get_next_set(&m_part_info->read_partitions, i))
{
file= m_file[i];
file->info(HA_STATUS_VARIABLE | no_lock_flag | extra_var_flag);
if ((error= file->info(HA_STATUS_VARIABLE | no_lock_flag | extra_var_flag)))
DBUG_RETURN(error);
stats.records+= file->stats.records;
stats.deleted+= file->stats.deleted;
stats.data_file_length+= file->stats.data_file_length;
......@@ -8494,7 +8500,8 @@ int ha_partition::info(uint flag)
if (!(flag & HA_STATUS_VARIABLE) ||
!bitmap_is_set(&(m_part_info->read_partitions),
(uint) (file_array - m_file)))
file->info(HA_STATUS_VARIABLE | no_lock_flag | extra_var_flag);
if ((error= file->info(HA_STATUS_VARIABLE | no_lock_flag | extra_var_flag)))
DBUG_RETURN(error);
if (file->stats.records > max_records || !handler_instance_set)
{
handler_instance_set= 1;
......@@ -8515,7 +8522,8 @@ int ha_partition::info(uint flag)
this);
file= m_file[handler_instance];
file->info(HA_STATUS_CONST | no_lock_flag);
if ((error= file->info(HA_STATUS_CONST | no_lock_flag)))
DBUG_RETURN(error);
stats.block_size= file->stats.block_size;
stats.create_time= file->stats.create_time;
ref_length= m_ref_length;
......@@ -8531,7 +8539,8 @@ int ha_partition::info(uint flag)
Note: all engines does not support HA_STATUS_ERRKEY, so set errkey.
*/
file->errkey= errkey;
file->info(HA_STATUS_ERRKEY | no_lock_flag);
if ((error= file->info(HA_STATUS_ERRKEY | no_lock_flag)))
DBUG_RETURN(error);
errkey= file->errkey;
}
if (flag & HA_STATUS_TIME)
......@@ -8548,7 +8557,8 @@ int ha_partition::info(uint flag)
do
{
file= *file_array;
file->info(HA_STATUS_TIME | no_lock_flag);
if ((error= file->info(HA_STATUS_TIME | no_lock_flag)))
DBUG_RETURN(error);
if (file->stats.update_time > stats.update_time)
stats.update_time= file->stats.update_time;
} while (*(++file_array));
......@@ -10523,11 +10533,11 @@ int ha_partition::cmp_ref(const uchar *ref1, const uchar *ref2)
the underlying partitions require that the value should be re-calculated
*/
void ha_partition::update_next_auto_inc_val()
int ha_partition::update_next_auto_inc_val()
{
if (!part_share->auto_inc_initialized ||
need_info_for_auto_inc())
info(HA_STATUS_AUTO);
if (!part_share->auto_inc_initialized || need_info_for_auto_inc())
return info(HA_STATUS_AUTO);
return 0;
}
......
......@@ -1361,7 +1361,7 @@ class ha_partition :public handler
virtual void release_auto_increment();
private:
virtual int reset_auto_increment(ulonglong value);
void update_next_auto_inc_val();
int update_next_auto_inc_val();
virtual void lock_auto_increment()
{
/* lock already taken */
......
#
# MDEV-26544 Assertion `part_share->auto_inc_initialized' failed in ha_partition::get_auto_increment on INSERT
#
for master_1
for child2
for child3
connection master_1;
CREATE DATABASE auto_test_remote;
USE auto_test_remote;
CREATE TABLE `tbl_a` (
`a` INT AUTO_INCREMENT, KEY(`a`)
) ENGINE=Spider DEFAULT CHARSET=utf8
PARTITION BY LIST COLUMNS (`a`) (
PARTITION `pt1` DEFAULT
);
INSERT INTO tbl_a (a) VALUES (0);
ERROR HY000: Unable to connect to foreign data source: localhost
INSERT INTO tbl_a () VALUES ();
ERROR HY000: Unable to connect to foreign data source: localhost
DROP DATABASE IF EXISTS auto_test_remote;
for master_1
for child2
for child3
!include include/default_mysqld.cnf
!include ../my_1_1.cnf
--echo #
--echo # MDEV-26544 Assertion `part_share->auto_inc_initialized' failed in ha_partition::get_auto_increment on INSERT
--echo #
--disable_query_log
--disable_result_log
--source ../../t/test_init.inc
--enable_result_log
--enable_query_log
--connection master_1
CREATE DATABASE auto_test_remote;
USE auto_test_remote;
eval CREATE TABLE `tbl_a` (
`a` INT AUTO_INCREMENT, KEY(`a`)
) $MASTER_1_ENGINE $MASTER_1_CHARSET
PARTITION BY LIST COLUMNS (`a`) (
PARTITION `pt1` DEFAULT
);
--error ER_CONNECT_TO_FOREIGN_DATA_SOURCE
INSERT INTO tbl_a (a) VALUES (0);
--error ER_CONNECT_TO_FOREIGN_DATA_SOURCE
INSERT INTO tbl_a () VALUES ();
DROP DATABASE IF EXISTS auto_test_remote;
--disable_query_log
--disable_result_log
--source ../../t/test_deinit.inc
--enable_result_log
--enable_query_log
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