Skip to content

Commit

Permalink
[storage/federated] PS-7999: FEDERATED engine not reconnecting on wai…
Browse files Browse the repository at this point in the history
…t_timeout exceeded

https://jira.percona.com/browse/PS-7999

Original commit caused error: percona@14508bbb179

Reconnection is lost because error is produced on reading query result, but reconnect is implemented only in `cli_advanced_command`, which sends commands. So we add reconnection on the full real query, but just for Federated to minimize possible issues. Similar reconnect logic was added for MySQL CLI Client, see mysql_real_query_for_lazy in 14508bb patch.
  • Loading branch information
voodam authored and inikep committed Jul 24, 2023
1 parent 576177e commit d218589
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 1 deletion.
27 changes: 27 additions & 0 deletions mysql-test/suite/federated/r/federated.result
Original file line number Diff line number Diff line change
Expand Up @@ -2444,6 +2444,33 @@ SELECT a, b FROM federated.t1;
a b
DROP TABLE federated.t1;
DROP TABLE federated.t1;
#
# Bug#105878: PS-7999: FEDERATED engine not reconnecting on wait_timeout exceeded
#
SET @OLD_SLAVE_WAIT_TIMEOUT= @@GLOBAL.WAIT_TIMEOUT;
SET @@GLOBAL.WAIT_TIMEOUT= 4;
CREATE TABLE test.t1 (id int PRIMARY KEY);
INSERT INTO test.t1 VALUES(1);
CREATE SERVER test FOREIGN DATA WRAPPER test1 OPTIONS(
user 'root',
password '',
host '127.0.0.1',
port SLAVE_PORT,
database 'test');
CREATE TABLE test.t1 (id int PRIMARY KEY) ENGINE=FEDERATED CONNECTION='test';
SELECT * FROM test.t1;
id
1
SELECT sleep(5);
sleep(5)
0
SELECT * from test.t1;
id
1
DROP TABLE test.t1;
DROP SERVER test;
DROP TABLE test.t1;
SET @@GLOBAL.WAIT_TIMEOUT= @OLD_SLAVE_WAIT_TIMEOUT;
SET @@GLOBAL.CONCURRENT_INSERT= @OLD_MASTER_CONCURRENT_INSERT;
SET @@GLOBAL.CONCURRENT_INSERT= @OLD_SLAVE_CONCURRENT_INSERT;
DROP TABLE IF EXISTS federated.t1;
Expand Down
29 changes: 29 additions & 0 deletions mysql-test/suite/federated/t/federated.test
Original file line number Diff line number Diff line change
Expand Up @@ -2151,6 +2151,35 @@ DROP TABLE federated.t1;
connection slave;
DROP TABLE federated.t1;

--echo #
--echo # Bug#105878: PS-7999: FEDERATED engine not reconnecting on wait_timeout exceeded
--echo #
connection slave;
SET @OLD_SLAVE_WAIT_TIMEOUT= @@GLOBAL.WAIT_TIMEOUT;
SET @@GLOBAL.WAIT_TIMEOUT= 4;
CREATE TABLE test.t1 (id int PRIMARY KEY);
INSERT INTO test.t1 VALUES(1);

connection master;
--replace_result $SLAVE_MYPORT SLAVE_PORT
eval CREATE SERVER test FOREIGN DATA WRAPPER test1 OPTIONS(
user 'root',
password '',
host '127.0.0.1',
port $SLAVE_MYPORT,
database 'test');
CREATE TABLE test.t1 (id int PRIMARY KEY) ENGINE=FEDERATED CONNECTION='test';

SELECT * FROM test.t1;
SELECT sleep(5);
SELECT * from test.t1;

DROP TABLE test.t1;
DROP SERVER test;
connection slave;
DROP TABLE test.t1;
SET @@GLOBAL.WAIT_TIMEOUT= @OLD_SLAVE_WAIT_TIMEOUT;

connection default;
SET @@GLOBAL.CONCURRENT_INSERT= @OLD_MASTER_CONCURRENT_INSERT;
connection slave;
Expand Down
3 changes: 2 additions & 1 deletion storage/federated/ha_federated.cc
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,8 @@ static int federated_db_init(void *p) {
federated_hton->commit = federated_commit;
federated_hton->rollback = federated_rollback;
federated_hton->create = federated_create_handler;
federated_hton->flags = HTON_ALTER_NOT_SUPPORTED | HTON_NO_PARTITION;
federated_hton->flags = HTON_ALTER_NOT_SUPPORTED | HTON_NO_PARTITION |
HTON_SUPPORTS_ONLINE_BACKUPS;

/*
Support for transactions disabled until WL#2952 fixes it.
Expand Down

0 comments on commit d218589

Please sign in to comment.