forked from facebook/mysql-5.6
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FB8-76: Add current master host:port to server read only error when a…
…vailable (facebook#958) Summary: Jira ticket: https://jira.percona.com/browse/FB8-76 Reference Patch: facebook@270854f Reference Patch: facebook@9f00827 Reference Patch: facebook@3e50e46 Reference Patch: facebook@9f18725 When a server is in read_only, we append the current master_host and master_port to the error message, if the server is a slave. The master_host could be either hostname or ip address, depending on how a slave is connected to the master. A new generic error code `ER_OPTION_PREVENTS_STATEMENT_EXTRA_INFO` is added, so that we can append any additional info to the fixed error message. Proposing a way to set a custom message in the `--read-only (super)` error. Note: the variable can only be set when server is in read-only (super) state. p.s. I am hesitant to add a mutex for the variable, so we will get a snapshot of the current pointer of the variable (const char*) when printing the error. Per request, we allow setting read_only_error_msg_extra without being in read_only state. The custom message can be set/reset at any time. D61383 added a new error code to allow appending extra info to read_only error message. The new error code breaks existing dependencies which expects to receive code 1290. Reverting back to use the old error, and extending the 1290 error message instead of adding a new one. This involves updating many files (which was the motivation I added a new one in D61383). Ideally we should have a more elegant solution to send extra info back to clients, which will be worked on separately. This is to fix the broken dependencies. Pull Request resolved: facebook#958 Test Plan: Updated rpl.rpl_read_only. Master_port is non-deterministic in the test, so I masked in the test result. Will update any test that comes up in the sandcastle if needed. Originally Reviewed By: santoshb Reviewed By: lth Differential Revision: D14137345 Pulled By: lth fbshipit-source-id: 13d23a2
- Loading branch information
Showing
18 changed files
with
123 additions
and
16 deletions.
There are no files selected for viewing
This file contains 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 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 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 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
22 changes: 22 additions & 0 deletions
22
mysql-test/suite/sys_vars/r/read_only_error_msg_extra_basic.result
This file contains 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,22 @@ | ||
set @@global.read_only_error_msg_extra='Custom message before read_only'; | ||
select @@global.read_only_error_msg_extra; | ||
@@global.read_only_error_msg_extra | ||
Custom message before read_only | ||
set global read_only = true; | ||
set @@global.read_only_error_msg_extra = default; | ||
select @@global.read_only_error_msg_extra; | ||
@@global.read_only_error_msg_extra | ||
|
||
set @saved_read_only_error_msg_extra = @@global.read_only_error_msg_extra; | ||
set @@global.read_only_error_msg_extra='This is a custom message'; | ||
set global super_read_only = true; | ||
set @@global.read_only_error_msg_extra='This is another custom message'; | ||
set @@global.read_only_error_msg_extra=1; | ||
ERROR 42000: Incorrect argument type to variable 'read_only_error_msg_extra' | ||
select @@session.read_only_error_msg_extra; | ||
ERROR HY000: Variable 'read_only_error_msg_extra' is a GLOBAL variable | ||
set @@session.read_only_error_msg_extra='This is a custom message'; | ||
ERROR HY000: Variable 'read_only_error_msg_extra' is a GLOBAL variable and should be set with SET GLOBAL | ||
set global read_only_error_msg_extra = @saved_read_only_error_msg_extra; | ||
set global super_read_only = false; | ||
set global read_only = false; |
25 changes: 25 additions & 0 deletions
25
mysql-test/suite/sys_vars/t/read_only_error_msg_extra_basic.test
This file contains 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,25 @@ | ||
set @@global.read_only_error_msg_extra='Custom message before read_only'; | ||
select @@global.read_only_error_msg_extra; | ||
|
||
set global read_only = true; | ||
set @@global.read_only_error_msg_extra = default; | ||
select @@global.read_only_error_msg_extra; | ||
set @saved_read_only_error_msg_extra = @@global.read_only_error_msg_extra; | ||
|
||
set @@global.read_only_error_msg_extra='This is a custom message'; | ||
|
||
set global super_read_only = true; | ||
set @@global.read_only_error_msg_extra='This is another custom message'; | ||
|
||
--error ER_WRONG_TYPE_FOR_VAR | ||
set @@global.read_only_error_msg_extra=1; | ||
|
||
--error ER_INCORRECT_GLOBAL_LOCAL_VAR | ||
select @@session.read_only_error_msg_extra; | ||
--error ER_GLOBAL_VARIABLE | ||
set @@session.read_only_error_msg_extra='This is a custom message'; | ||
|
||
set global read_only_error_msg_extra = @saved_read_only_error_msg_extra; | ||
|
||
set global super_read_only = false; | ||
set global read_only = false; |
This file contains 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 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 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 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 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 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 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 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 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 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 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 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