MDEV-38202: make init_rpl_role visible at runtime#4904
MDEV-38202: make init_rpl_role visible at runtime#4904Mahmoud-kh1 wants to merge 1 commit intoMariaDB:mainfrom
Conversation
f6f6a30 to
029860e
Compare
gkodinov
left a comment
There was a problem hiding this comment.
Thank you for your contribution! This is a preliminary review.
Please, in addition to the notes below:
- add a commit message to your commit explaining what it is that you do
- update the Jira with a complete description of what the new variable is (data type, validity period, purpose), when and how it can be set, etc. : helps documenting it.
- Make sure that there are no failing buildbot hosts.
|
|
||
| --echo # it should show in INFORMATION_SCHEMA.GLOBAL_VARIABLES | ||
| SELECT * FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES | ||
| WHERE VARIABLE_NAME = 'init_rpl_role'; No newline at end of file |
There was a problem hiding this comment.
Please always terminate the last line with a new line.
We also customarily add a --echo # End of MA.MI tests at the end: helps conflict resolution when merging up and down.
| NOT_IN_BINLOG, ON_CHECK(check_init_string)); | ||
|
|
||
| #ifdef HAVE_REPLICATION | ||
| static Sys_var_enum Sys_init_rpl_role( |
There was a problem hiding this comment.
Feel free to leave that to the final reviewer. But: is there any specific reason this should be a system variable?
It's read only at runtime and not settable via the command line/config file at startup. So, in essence, you can only read it. So why not make this a status variable?
There was a problem hiding this comment.
I just make it system variable to support this syntax
SELECT @@global.init_rpl_role;
SELECT @@init_rpl_role;
There was a problem hiding this comment.
again, why? what's better about this syntax compared to SHOW GLOBAL STATUS LIKE 'init_rpl_role' ?
There was a problem hiding this comment.
I thought it will be just a nice bonus :) , I will turn it to status variable as you suggested.
There was a problem hiding this comment.
I stumbled upon the System & Status Variables Guide.
In general, I believe this should be a system variable, as it’s associated with a mode configuration rather than a status report.
In theory, it is possible to make --init-rpl-role mutable during runtime for recovering complex Semi-Sync networks/situations.
But in practice, --init-rpl-role doesn’t scale. (see also MDEV-34878)
There was a problem hiding this comment.
FWIW, I've requested that this is a status variable for the following reasons:
- I've assumed that a value will never be assigned directly to it.
- Status variables are more light-weight than system variables: less locking needed etc.
- I personally find a non-settable system variable to be an abomination and a gotcha: why would you put something non-settable in a settable variables namespace?
This said, it's your review and your codebase. So feel free to ignore the above or not.
There was a problem hiding this comment.
- I've assumed that a value will never be assigned directly to it.
- Status variables are more light-weight than system variables: less locking needed etc.
- I personally find a non-settable system variable to be an abomination and a gotcha: why would you put something non-settable in a settable variables namespace?
There are existing global read-only variables.
But yes, the system variables system should solve these missed optimizations.
There was a problem hiding this comment.
Hi @ParadoxV5 I return it back to be a system variable .
sql/sys_vars.cc
Outdated
| "The replication role that the server was started with. " | ||
| "Possible values are MASTER and SLAVE", | ||
| READ_ONLY GLOBAL_VAR(init_rpl_role_val), NO_CMD_LINE, | ||
| rpl_role_type, DEFAULT(RPL_AUTH_MASTER)); |
There was a problem hiding this comment.
Do you really need a default here? You're going to always set it.
There was a problem hiding this comment.
I see rp_status has it as default value so I follow it
There was a problem hiding this comment.
What I implied is that you will never see this default value. So you might just as well put 0 here.
1979739 to
8795f3b
Compare
gkodinov
left a comment
There was a problem hiding this comment.
Thank you for making it a status variable!
Some cleanups below. And then it's ready.
8795f3b to
648ee9c
Compare
| NOT_IN_BINLOG, ON_CHECK(check_init_string)); | ||
|
|
||
| #ifdef HAVE_REPLICATION | ||
| static Sys_var_enum Sys_init_rpl_role( |
There was a problem hiding this comment.
I stumbled upon the System & Status Variables Guide.
In general, I believe this should be a system variable, as it’s associated with a mode configuration rather than a status report.
In theory, it is possible to make --init-rpl-role mutable during runtime for recovering complex Semi-Sync networks/situations.
But in practice, --init-rpl-role doesn’t scale. (see also MDEV-34878)
gkodinov
left a comment
There was a problem hiding this comment.
LGTM. Thank you for your work. Please stay tuned for the final review.
648ee9c to
c732a37
Compare
ParadoxV5
left a comment
There was a problem hiding this comment.
Thanks and well done on the first-time contribution, @Mahmoud-kh1!
sql/sys_vars.cc
Outdated
| "The replication role that the server was started with" | ||
| "Possible values are MASTER and SLAVE", | ||
| READ_ONLY GLOBAL_VAR(init_rpl_role_val), NO_CMD_LINE, | ||
| rpl_role_type, DEFAULT(RPL_AUTH_MASTER)); |
There was a problem hiding this comment.
Recommendation: Move --init-rpl-role from sql/mysqld.cc here.
| "The replication role that the server was started with" | |
| "Possible values are MASTER and SLAVE", | |
| READ_ONLY GLOBAL_VAR(init_rpl_role_val), NO_CMD_LINE, | |
| rpl_role_type, DEFAULT(RPL_AUTH_MASTER)); | |
| "Set the replication role <insert mention of semi-sync recovery here>" | |
| READ_ONLY GLOBAL_VAR(init_rpl_role_val), CMD_LINE(REQUIRED_ARG), | |
| rpl_role_type, DEFAULT(RPL_AUTH_MASTER)); |
(I’m surprised to see --init-rpl-role hooked directly onto the status variable Rpl_status in sql/mysqld.cc, which changes live and is most likely not what users expect @@init_rpl_role to be, if not Semi-Sync Recovery itself…
Not to mention finer Rpl_status alternatives in SHOW REPLICA STATUS.)
There was a problem hiding this comment.
Hint: How should rpl_status (status variable Rpl_status) be initialized, now that you’ve unregistered it in sql/mysqld.cc?
There was a problem hiding this comment.
yeah I see , I should assign it to the new variable I made now it will never be updated :)
There was a problem hiding this comment.
Please add test-to-fails for not SESSION scope and Read-only as well.
💭(Why? Because they aren’t merely “alternative syntaxes”… I wonder if all these _basic.tests could’ve instead been a single information_schema.system_variables-based script similar to sys_vars.sysvars_server_notembedded. reference)
There was a problem hiding this comment.
The test LGTM except… nits. These double-blankline separators, upper/lower case inconsistencies, and sentences without capitalization and full stops itch me.
98393ff to
d9aa486
Compare
sql/sys_vars.cc
Outdated
| "The replication role that the server was started with" | ||
| "Possible values are MASTER and SLAVE", | ||
| READ_ONLY GLOBAL_VAR(init_rpl_role_val), NO_CMD_LINE, | ||
| rpl_role_type, DEFAULT(RPL_AUTH_MASTER)); |
There was a problem hiding this comment.
Hint: How should rpl_status (status variable Rpl_status) be initialized, now that you’ve unregistered it in sql/mysqld.cc?
There was a problem hiding this comment.
The test LGTM except… nits. These double-blankline separators, upper/lower case inconsistencies, and sentences without capitalization and full stops itch me.
37a4765 to
e74a17c
Compare
There was a problem hiding this comment.
Are you still cleaning up?
The expected results of sys_vars.sysvars_server_notembedded and main.mysqld--help tests need updates to match the new refined description.
You can have path/to/mtr --record suite_name.test_name rewrite the results if you don’t like manual copy-pastes.
While there, some small details that I missed last time:
- Your added lines have numerous (unnecessary) trailing spaces. Please clean them up.
- Re. the commit message
- It still says “status variable” 😄.
- The last paragraph of your commit message (added later?) exceeds the guidelines.
I suggest breaking the line up:Example usage: * SHOW GLOBAL VARIABLES LIKE 'init_rpl_role' * SELECT @@GLOBAL.init_rpl_role;
- Would you like to include the reviewers?
Reviewed-by: ParadoxV5 <paradox.ver5@gmail.com> Reviewed-by: Georgi (Joro) Kodinov <joro@mariadb.org>
- Nit: doubled space in
… investigation issues because
| --echo # MDEV-38202: add init_rpl_role in output of "show variables" | ||
| --echo # | ||
|
|
||
| --echo # it should show SLAVE as it is set in opt file |
There was a problem hiding this comment.
| --echo # it should show SLAVE as it is set in opt file | |
| --echo # It should show SLAVE as it is set in the .opt file. |
5c4cdcd to
839be78
Compare
Problem: The --init-rpl-role option can be set in the .cnf file or command line to configure the server replication role at startup (MASTER or SLAVE), but there was no way to check this value at runtime. This made it hard to investigate issues because we could not know which role the server was started with. Solution: I added a new read-only system variable init_rpl_role that is set after startup and kept unchanged. Example usage: * SHOW GLOBAL VARIABLES LIKE 'init_rpl_role' * SELECT @@GLOBAL.init_rpl_role Reviewed-by: ParadoxV5 <paradox.ver5@gmail.com> Reviewed-by: Georgi (Joro) Kodinov <joro@mariadb.org>
839be78 to
8f83b3b
Compare
This PR adds a new feature to see the server’s initial replication role at runtime.
I added a new read-only status variable init_rpl_role that captures the value of rpl_status right after startup and keeps it unchanged.
Reason
Previously,
init_rpl_rolecould be set in the cnf file but was not visible in runtime which will be helpful for investigating issues as it will allow us to see with which value mariadb was started.Tests :
Added basic tests to verify that
init_rpl_roleis correctly set at startup and displayed properly.