Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions mysql-test/main/information_schema.result
Original file line number Diff line number Diff line change
Expand Up @@ -1939,6 +1939,7 @@ drop table if exists t1;drop table if exists t1;
drop table if exists t1;drop table if exists t1;
drop table if exists t1;drop table if exists t1;
INIT_FILE
INIT_RPL_ROLE MASTER
INIT_SLAVE
set global init_connect="";
create table t0 select * from information_schema.global_status where VARIABLE_NAME='COM_SELECT';
Expand Down
4 changes: 3 additions & 1 deletion mysql-test/main/mysqld--help.result
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,9 @@ The following specify which files/extra groups are read (specified before remain
(unless the user has SUPER privilege)
--init-file=name Read SQL commands from this file at startup
--init-rpl-role=name
Set the replication role. One of: MASTER, SLAVE
The replication role the server starts with. Can be set
to help recover special semi-sync replication situations.
Possible values are MASTER and SLAVE
--init-slave=name Command(s) that are executed by a slave server each time
the SQL thread starts
--interactive-timeout=#
Expand Down
17 changes: 17 additions & 0 deletions mysql-test/suite/sys_vars/r/init_rpl_role_variable_basic.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#
# MDEV-38202: add init_rpl_role in output of "show variables"
#
# It should show SLAVE as it is set in the .opt file.
SELECT @@GLOBAL.init_rpl_role;
@@GLOBAL.init_rpl_role
SLAVE
SHOW GLOBAL VARIABLES LIKE 'init_rpl_role';
Variable_name Value
init_rpl_role SLAVE
# Verify that it's a global scope only.
SELECT @@SESSION.init_rpl_role;
ERROR HY000: Variable 'init_rpl_role' is a GLOBAL variable
# Verify it's read-only.
SET @@GLOBAL.init_rpl_role = 'MASTER';
ERROR HY000: Variable 'init_rpl_role' is a read only variable
# End of 13.0 tests
10 changes: 10 additions & 0 deletions mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result
Original file line number Diff line number Diff line change
Expand Up @@ -1582,6 +1582,16 @@ NUMERIC_BLOCK_SIZE NULL
ENUM_VALUE_LIST NULL
READ_ONLY YES
COMMAND_LINE_ARGUMENT REQUIRED
VARIABLE_NAME INIT_RPL_ROLE
VARIABLE_SCOPE GLOBAL
VARIABLE_TYPE ENUM
VARIABLE_COMMENT The replication role the server starts with. Can be set to help recover special semi-sync replication situations. Possible values are MASTER and SLAVE
NUMERIC_MIN_VALUE NULL
NUMERIC_MAX_VALUE NULL
NUMERIC_BLOCK_SIZE NULL
ENUM_VALUE_LIST MASTER,SLAVE
READ_ONLY YES
COMMAND_LINE_ARGUMENT REQUIRED
VARIABLE_NAME INIT_SLAVE
VARIABLE_SCOPE GLOBAL
VARIABLE_TYPE VARCHAR
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--init-rpl-role=SLAVE
18 changes: 18 additions & 0 deletions mysql-test/suite/sys_vars/t/init_rpl_role_variable_basic.test
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test LGTM except… nits. These double-blankline separators, upper/lower case inconsistencies, and sentences without capitalization and full stops itch me.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok , I will clean it now.

Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
--source include/not_embedded.inc
--echo #
--echo # MDEV-38202: add init_rpl_role in output of "show variables"
--echo #

--echo # It should show SLAVE as it is set in the .opt file.
SELECT @@GLOBAL.init_rpl_role;
SHOW GLOBAL VARIABLES LIKE 'init_rpl_role';

--echo # Verify that it's a global scope only.
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
SELECT @@SESSION.init_rpl_role;

--echo # Verify it's read-only.
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
SET @@GLOBAL.init_rpl_role = 'MASTER';

--echo # End of 13.0 tests
4 changes: 1 addition & 3 deletions sql/mysqld.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7086,9 +7086,6 @@ struct my_option my_long_options[]=
"which is whether to validate the master's certificate in TLS replication",
&master_ssl_verify_server_cert, nullptr, nullptr, GET_BOOL, NO_ARG,
master_ssl_verify_server_cert, 0, 0, nullptr, 0, nullptr},
{"init-rpl-role", 0, "Set the replication role",
&rpl_status, &rpl_status, &rpl_role_typelib,
GET_ENUM, REQUIRED_ARG, RPL_AUTH_MASTER, 0, 0, 0, 0, 0},
#endif /* HAVE_REPLICATION */
{"memlock", 0, "Lock mariadbd process in memory", &locked_in_memory,
&locked_in_memory, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
Expand Down Expand Up @@ -9141,6 +9138,7 @@ static int get_options(int *argc_ptr, char ***argv_ptr)
flush_time= 0;

#ifdef HAVE_REPLICATION
rpl_status= init_rpl_role_val;
if (init_slave_skip_errors(opt_slave_skip_errors))
return 1;
if (init_slave_transaction_retry_errors(opt_slave_transaction_retry_errors))
Expand Down
1 change: 1 addition & 0 deletions sql/repl_failsafe.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ struct Slave_info

Atomic_counter<uint32_t> binlog_dump_thread_count;
ulong rpl_status=RPL_NULL;
ulong init_rpl_role_val= 0;
mysql_mutex_t LOCK_rpl_status;

const char *rpl_role_type[] = {"MASTER","SLAVE",NullS};
Expand Down
1 change: 1 addition & 0 deletions sql/repl_failsafe.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ typedef enum {RPL_AUTH_MASTER=0,RPL_IDLE_SLAVE,RPL_ACTIVE_SLAVE,
RPL_ANY /* wild card used by change_rpl_status */ } RPL_STATUS;
extern ulong rpl_status;

extern ulong init_rpl_role_val;
extern mysql_mutex_t LOCK_rpl_status;
extern mysql_cond_t COND_rpl_status;
extern TYPELIB rpl_role_typelib;
Expand Down
11 changes: 11 additions & 0 deletions sql/sys_vars.cc
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
#include "semisync_master.h"
#include "semisync_slave.h"
#include <ssl_compat.h>
#include "repl_failsafe.h"
#ifdef WITH_WSREP
#include "wsrep_mysqld.h"
#endif
Expand Down Expand Up @@ -1505,6 +1506,16 @@ Sys_init_slave(
DEFAULT(""), &PLock_sys_init_slave,
NOT_IN_BINLOG, ON_CHECK(check_init_string));

#ifdef HAVE_REPLICATION
static Sys_var_enum Sys_init_rpl_role(
"init_rpl_role",
"The replication role the server starts with. "
"Can be set to help recover "
"special semi-sync replication situations. "
"Possible values are MASTER and SLAVE",
READ_ONLY GLOBAL_VAR(init_rpl_role_val), CMD_LINE(REQUIRED_ARG),
rpl_role_type, DEFAULT(RPL_AUTH_MASTER));
#endif
static Sys_var_ulong Sys_interactive_timeout(
"interactive_timeout",
"The number of seconds the server waits for activity on an interactive "
Expand Down