Commit fd767462 authored by Yuchen Pei's avatar Yuchen Pei

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).
parent a6ae1c2d
...@@ -9396,18 +9396,6 @@ int ha_spider::update_auto_increment() ...@@ -9396,18 +9396,6 @@ int ha_spider::update_auto_increment()
DBUG_ENTER("ha_spider::update_auto_increment"); DBUG_ENTER("ha_spider::update_auto_increment");
DBUG_PRINT("info",("spider this=%p", this)); DBUG_PRINT("info",("spider this=%p", this));
force_auto_increment = TRUE; 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", DBUG_PRINT("info",("spider auto_increment_mode=%d",
auto_increment_mode)); auto_increment_mode));
DBUG_PRINT("info",("spider next_number_field=%lld", DBUG_PRINT("info",("spider next_number_field=%lld",
...@@ -9662,7 +9650,12 @@ int ha_spider::write_row( ...@@ -9662,7 +9650,12 @@ int ha_spider::write_row(
pthread_mutex_lock(&share->lgtm_tblhnd_share->auto_increment_mutex); pthread_mutex_lock(&share->lgtm_tblhnd_share->auto_increment_mutex);
if (!share->lgtm_tblhnd_share->auto_increment_init) 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 = share->lgtm_tblhnd_share->auto_increment_lclval =
stats.auto_increment_value; stats.auto_increment_value;
share->lgtm_tblhnd_share->auto_increment_init = TRUE; share->lgtm_tblhnd_share->auto_increment_init = TRUE;
......
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
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
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