Skip to content

Commit 87ddbd2

Browse files
committed
MDEV-39196: SELECT from information schema fails when FederatedX loses underlying table
When a remote table is unavailable, FederatedX was passing a hard error back to the SQL layer, causing INFORMATION_SCHEMA queries to abort entirely. This patch intercepts the remote error in ha_federatedx::info, downgrades it to a warning using push_warning_printf, and includes the local table name in the warning message so the user knows which table is inaccessible. Signed-off-by: Anway Durge <124391429+itzanway@users.noreply.github.com>
1 parent b4bc43e commit 87ddbd2

3 files changed

Lines changed: 58 additions & 3 deletions

File tree

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# MDEV-39196: SELECT * FROM i_s.schema fails when federatedX disconnects
2+
CREATE SERVER fedlink FOREIGN DATA WRAPPER MYSQL OPTIONS (
3+
HOST "127.0.0.1", DATABASE "test", USER "root", PORT MASTER_MYPORT);
4+
CREATE TABLE fed_t (a INT) ENGINE=FEDERATED CONNECTION = 'fedlink/t';
5+
# Querying Information Schema before dropping the remote table
6+
SELECT TABLE_NAME, ENGINE FROM INFORMATION_SCHEMA.TABLES
7+
WHERE TABLE_SCHEMA = 'test' AND TABLE_NAME IN ('t', 'fed_t');
8+
TABLE_NAME ENGINE
9+
fed_t FEDERATED
10+
t InnoDB
11+
DROP TABLE t;
12+
# Querying Information Schema AFTER dropping the remote table
13+
# (this used to return an error without completing)
14+
SELECT TABLE_NAME, ENGINE FROM INFORMATION_SCHEMA.TABLES
15+
WHERE TABLE_SCHEMA = 'test' AND TABLE_NAME IN ('t', 'fed_t');
16+
TABLE_NAME ENGINE
17+
fed_t FEDERATED
18+
# Cleanup
19+
DROP TABLE fed_t;
20+
DROP SERVER fedlink;
21+
End of 10.11 tests.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
--source include/not_embedded.inc
2+
--echo # MDEV-39196: SELECT * FROM i_s.schema fails when federatedX disconnects
3+
4+
--enable_warnings
5+
--replace_result $MASTER_MYPORT MASTER_MYPORT
6+
eval CREATE SERVER fedlink FOREIGN DATA WRAPPER MYSQL OPTIONS (
7+
HOST "127.0.0.1", DATABASE "test", USER "root", PORT $MASTER_MYPORT);
8+
9+
CREATE TABLE fed_t (a INT) ENGINE=FEDERATED CONNECTION = 'fedlink/t';
10+
11+
--echo # Querying Information Schema before dropping the remote table
12+
SELECT TABLE_NAME, ENGINE FROM INFORMATION_SCHEMA.TABLES
13+
WHERE TABLE_SCHEMA = 'test' AND TABLE_NAME IN ('t', 'fed_t');
14+
15+
DROP TABLE t;
16+
17+
--echo # Querying Information Schema AFTER dropping the remote table
18+
--echo # (this used to return an error without completing)
19+
SELECT TABLE_NAME, ENGINE FROM INFORMATION_SCHEMA.TABLES
20+
WHERE TABLE_SCHEMA = 'test' AND TABLE_NAME IN ('t', 'fed_t');
21+
22+
--echo # Cleanup
23+
DROP TABLE fed_t;
24+
DROP SERVER fedlink;
25+
26+
--echo End of 10.11 tests.

storage/federatedx/ha_federatedx.cc

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3130,13 +3130,21 @@ int ha_federatedx::info(uint flag)
31303130
error:
31313131
if (iop && *iop)
31323132
{
3133-
my_printf_error((*iop)->error_code(), "Received error: %d : %s", MYF(0),
3134-
(*iop)->error_code(), (*iop)->error_str());
3133+
/* Downgrade to warning, include the table name, and continue */
3134+
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
3135+
ER_QUERY_ON_FOREIGN_DATA_SOURCE,
3136+
"Table '%s' is inaccessible. Received error: %d : %s",
3137+
share->table_name, (*iop)->error_code(), (*iop)->error_str());
3138+
error_code= 0;
31353139
}
31363140
else if (remote_error_number != -1 /* error already reported */)
31373141
{
31383142
error_code= remote_error_number;
3139-
my_error(error_code, MYF(0), ER_THD(thd, error_code));
3143+
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
3144+
error_code,
3145+
"Table '%s' is inaccessible. Error: %s",
3146+
share->table_name, ER_THD(thd, error_code));
3147+
error_code= 0;
31403148
}
31413149
fail:
31423150
tmp_txn->release(&tmp_io);

0 commit comments

Comments
 (0)