Skip to content

Commit

Permalink
MDEV-28105 Return error in ha_spider::write_row() if info(HA_STATUS_A…
Browse files Browse the repository at this point in the history
…UTO) 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).
  • Loading branch information
mariadb-YuchenPei committed May 14, 2024
1 parent a6ae1c2 commit fd76746
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 13 deletions.
19 changes: 6 additions & 13 deletions storage/spider/ha_spider.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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;
Expand Down
10 changes: 10 additions & 0 deletions storage/spider/mysql-test/spider/bugfix/r/mdev_28105.result
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions storage/spider/mysql-test/spider/bugfix/t/mdev_28105.opt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--skip-log-bin
8 changes: 8 additions & 0 deletions storage/spider/mysql-test/spider/bugfix/t/mdev_28105.test
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit fd76746

Please sign in to comment.