MDEV-28105 Return error in ha_spider::write_row() if info(HA_STATUS_AUTO) fails

Spider calls info with HA_STATUS_AUTO to update auto increment info,
which may attempt to connect the data node. If the connection fails,
it may emit an error and return the same error. This error should not
be of lower priority than any possible error from the later call to
handler::update_auto_increment().

Without this change, certain errors from update_auto_increment() such
as HA_ERR_AUTOINC_ERANGE may get ignored, causing my_insert() to call
my_ok(), which fails the assertion because the error was emitted in
the info() call (Diagnostics_area::is_set() returns true).
This commit is contained in:
Yuchen Pei 2024-05-07 13:49:17 +10:00
parent a6ae1c2dfb
commit fd76746234
No known key found for this signature in database
GPG key ID: 3DD1B35105743563
4 changed files with 25 additions and 13 deletions

View file

@ -9396,18 +9396,6 @@ int ha_spider::update_auto_increment()
DBUG_ENTER("ha_spider::update_auto_increment");
DBUG_PRINT("info",("spider this=%p", this));
force_auto_increment = TRUE;
/*
if (
next_insert_id >= auto_inc_interval_for_cur_row.maximum() &&
wide_handler->trx->thd->auto_inc_intervals_forced.get_current()
) {
force_auto_increment = TRUE;
DBUG_PRINT("info",("spider force_auto_increment=TRUE"));
} else {
force_auto_increment = FALSE;
DBUG_PRINT("info",("spider force_auto_increment=FALSE"));
}
*/
DBUG_PRINT("info",("spider auto_increment_mode=%d",
auto_increment_mode));
DBUG_PRINT("info",("spider next_number_field=%lld",
@ -9662,7 +9650,12 @@ int ha_spider::write_row(
pthread_mutex_lock(&share->lgtm_tblhnd_share->auto_increment_mutex);
if (!share->lgtm_tblhnd_share->auto_increment_init)
{
info(HA_STATUS_AUTO);
if ((error_num= info(HA_STATUS_AUTO)))
{
pthread_mutex_unlock(
&share->lgtm_tblhnd_share->auto_increment_mutex);
DBUG_RETURN(error_num);
}
share->lgtm_tblhnd_share->auto_increment_lclval =
stats.auto_increment_value;
share->lgtm_tblhnd_share->auto_increment_init = TRUE;

View file

@ -0,0 +1,10 @@
install soname 'ha_spider';
Warnings:
Warning 1105 Cannot enable tc-log at run-time. XA features of SPIDER are disabled
SET @@insert_id=128;
CREATE TABLE t(c TINYINT AUTO_INCREMENT KEY) ENGINE=Spider;
INSERT IGNORE INTO t VALUES(0);
ERROR HY000: Unable to connect to foreign data source: localhost
drop table t;
Warnings:
Warning 1620 Plugin is busy and will be uninstalled on shutdown

View file

@ -0,0 +1 @@
--skip-log-bin

View file

@ -0,0 +1,8 @@
install soname 'ha_spider';
SET @@insert_id=128; # 127 does not crash
CREATE TABLE t(c TINYINT AUTO_INCREMENT KEY) ENGINE=Spider;
--error ER_CONNECT_TO_FOREIGN_DATA_SOURCE
INSERT IGNORE INTO t VALUES(0);
drop table t;
--disable_query_log
--source ../../include/clean_up_spider.inc