-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
MDEV-39196: SELECT from information schema fails when FederatedX loses underlying table #4876
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
itzanway
wants to merge
1
commit into
MariaDB:10.11
Choose a base branch
from
itzanway:fix-mdev-39196
base: 10.11
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| connect master,127.0.0.1,root,,test,$MASTER_MYPORT,; | ||
| connect slave,127.0.0.1,root,,test,$SLAVE_MYPORT,; | ||
| connection master; | ||
| CREATE DATABASE federated; | ||
| connection slave; | ||
| CREATE DATABASE federated; | ||
| # | ||
| # MDEV-39196: INFORMATION_SCHEMA query must succeed with a | ||
| # warning when a FederatedX remote table is unreachable. | ||
| # | ||
| connection slave; | ||
| USE federated; | ||
| CREATE TABLE t1 ( | ||
| id INT NOT NULL, | ||
| name VARCHAR(64) | ||
| ) ENGINE=MyISAM; | ||
| INSERT INTO t1 VALUES (1, 'foo'); | ||
| connection master; | ||
| USE federated; | ||
| CREATE TABLE t1 ( | ||
| id INT NOT NULL, | ||
| name VARCHAR(64) | ||
| ) ENGINE=FEDERATED | ||
| CONNECTION='mysql://root@127.0.0.1:SLAVE_PORT/federated/t1'; | ||
| # Verify the federated table works before dropping remote table. | ||
| SELECT * FROM federated.t1; | ||
| id name | ||
| 1 foo | ||
| # Drop the remote table to simulate unreachable/missing table. | ||
| connection slave; | ||
| USE federated; | ||
| DROP TABLE t1; | ||
| connection master; | ||
| # INFORMATION_SCHEMA query must succeed and issue a warning. | ||
| SELECT TABLE_NAME, TABLE_ROWS | ||
| FROM information_schema.TABLES | ||
| WHERE TABLE_SCHEMA = 'federated' | ||
| AND TABLE_NAME = 't1'; | ||
| TABLE_NAME TABLE_ROWS | ||
| t1 1 | ||
| Warnings: | ||
| Warning 1430 FederatedX: Table 't1' is inaccessible: 1146 : Remote table does not exist | ||
| # Warning must be present. | ||
| SHOW WARNINGS; | ||
| Level Code Message | ||
| Warning 1430 FederatedX: Table 't1' is inaccessible: 1146 : Remote table does not exist | ||
| # Cleanup. | ||
| connection master; | ||
| DROP TABLE IF EXISTS federated.t1; | ||
| DROP DATABASE IF EXISTS federated; | ||
| connection slave; | ||
| DROP TABLE IF EXISTS federated.t1; | ||
| DROP DATABASE IF EXISTS federated; |
|
gkodinov marked this conversation as resolved.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| --source include/not_embedded.inc | ||
| --source have_federatedx.inc | ||
| --source include/federated.inc | ||
|
|
||
| --echo # | ||
| --echo # MDEV-39196: INFORMATION_SCHEMA query must succeed with a | ||
| --echo # warning when a FederatedX remote table is unreachable. | ||
| --echo # | ||
|
|
||
| connection slave; | ||
| USE federated; | ||
| CREATE TABLE t1 ( | ||
| id INT NOT NULL, | ||
| name VARCHAR(64) | ||
| ) ENGINE=MyISAM; | ||
| INSERT INTO t1 VALUES (1, 'foo'); | ||
|
|
||
| connection master; | ||
| USE federated; | ||
| --replace_result $SLAVE_MYPORT SLAVE_PORT | ||
| eval CREATE TABLE t1 ( | ||
| id INT NOT NULL, | ||
| name VARCHAR(64) | ||
| ) ENGINE=FEDERATED | ||
| CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/federated/t1'; | ||
|
|
||
| --echo # Verify the federated table works before dropping remote table. | ||
| SELECT * FROM federated.t1; | ||
|
|
||
| --echo # Drop the remote table to simulate unreachable/missing table. | ||
| connection slave; | ||
| USE federated; | ||
| DROP TABLE t1; | ||
|
|
||
| connection master; | ||
| --echo # INFORMATION_SCHEMA query must succeed and issue a warning. | ||
| SELECT TABLE_NAME, TABLE_ROWS | ||
| FROM information_schema.TABLES | ||
| WHERE TABLE_SCHEMA = 'federated' | ||
| AND TABLE_NAME = 't1'; | ||
|
|
||
| --echo # Warning must be present. | ||
| SHOW WARNINGS; | ||
|
|
||
| --echo # Cleanup. | ||
| --source include/federated_cleanup.inc |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3130,12 +3130,48 @@ int ha_federatedx::info(uint flag) | |
| error: | ||
| if (iop && *iop) | ||
| { | ||
| my_printf_error((*iop)->error_code(), "Received error: %d : %s", MYF(0), | ||
| (*iop)->error_code(), (*iop)->error_str()); | ||
| if ((flag & HA_STATUS_VARIABLE) && !(flag & HA_STATUS_NO_LOCK)) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add a comment here explaining what is it that you're testing for. |
||
| { | ||
|
Comment on lines
+3133
to
+3134
|
||
| push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, | ||
| ER_QUERY_ON_FOREIGN_DATA_SOURCE, | ||
| "FederatedX: Table '%s' is inaccessible: " | ||
| "%d : %s", | ||
| share->table_name, | ||
| (*iop)->error_code(), | ||
| (*iop)->error_str()); | ||
| error_code= 0; | ||
| } | ||
| else | ||
| { | ||
| my_printf_error((*iop)->error_code(), | ||
| ": %d : %s", MYF(0), | ||
| (*iop)->error_code(), (*iop)->error_str()); | ||
|
Comment on lines
+3146
to
+3148
|
||
| error_code= (*iop)->error_code(); | ||
| } | ||
| } | ||
| else if (remote_error_number != -1 /* error already reported */) | ||
| { | ||
| error_code= remote_error_number; | ||
| /* | ||
| * Downgrade remote errors to warnings only when called from the | ||
| * INFORMATION_SCHEMA table scan path. | ||
| * | ||
| * INFORMATION_SCHEMA scans (sql_show.cc, fill_schema_table_by_open) | ||
| * call ha_federatedx::info() with HA_STATUS_VARIABLE set but WITHOUT | ||
| * HA_STATUS_NO_LOCK. All other callers that trigger the error path | ||
| * (e.g. direct SELECT, DELETE, SHOW TABLE STATUS) pass | ||
| * HA_STATUS_NO_LOCK alongside HA_STATUS_VARIABLE. | ||
| * | ||
| * This combination is therefore used as an indirect signal that we are | ||
| * inside an I_S scan, where aborting with a hard error would break the | ||
| * entire query rather than just skipping the inaccessible table. | ||
| * | ||
| * NOTE: This is an indirect inference based on current caller conventions. | ||
| * If a future caller passes HA_STATUS_VARIABLE without HA_STATUS_NO_LOCK | ||
| * for a non-I_S purpose, it would unintentionally receive | ||
| * warning-downgrade behavior. A cleaner long-term solution would be an | ||
| * explicit flag or context distinguishing I_S scans from direct access. | ||
| */ | ||
| my_error(error_code, MYF(0), ER_THD(thd, error_code)); | ||
| } | ||
|
Comment on lines
3152
to
3176
|
||
| fail: | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.