WL#14450: Make skip-slave-start a global, persistable, read-only system variable
EXECUTIVE SUMMARY
The goal of this worklog is to allow the control over whether or not the
replica threads start upon server restart to be extended to MySQL users and
MySQL privilege infra-structure. At the moment, only operating system
privileged users may add --skip-slave-start
to control it, as a parameter
and at server bootstrap.
More specifically, the worklog will transform the --skip-slave-start
command line parameter into skip_slave_start
, a global, persistable,
read-only system variable.
USER STORIES
As a DBA, need to control whether or not the replica applier starts upon
server restart, without having the necessary privileges or access to the
operating system infra-structure needed to pass --skip-slave-start
upon
server start and without having to clear replication channel
configurations. Will achieve it by using SET PERSIST_ONLY
with the
skip_slave_start
global variable.
As a DBA, need to understand if the replica applier started when the server
was started in order to debug or troubleshoot issues with my running
instance. Will achieve it by consulting the value of the skip_slave_start
global variable.
As an external tool configuring InnoDB ClusterSets, need to prevent
replication channels to start automatically upon server start when: GR
fails to initiate upon server restart, after a primary election where the
server became a secondary; group_replication_start_on_boot
is
disabled. In either case, it's needed by external tools (Shell/AdminAPI)
to: query the state of skip_slave_start
;
change the value of
skip_slave_start
to prevent replication applier to start when GR isn't
started, blocking the proper configuration to be triggered.
IDENTIFIED REQUIREMENTS
R1. Variable skip_slave_start
shall exist as a global, read-only,
persistable variable.
R2. All forms of --skip-slave-start
command line parameter that are
allowed before the worklog, shall be allowed after the worklog.
PROPOSED APPROACH
Re-using the current already in-place infra-structure around the
--skip-slave-start
parameter (i.e., internal global variable), a
read-only and persist-only variable will be added using the sys_var
API.
Name and description are kept, as is the ability to set the variable through the command line.
IMPACT ANALYSIS
User Interface
skip_slave_start
system variable
- NAME:
skip_slave_start
- VALUES: ON, OFF, TRUE, FALSE, 1, 0
- DEFAULT: OFF
- SCOPE: GLOBAL
- REPLICATED: No
- DYNAMIC: No, read-only
- PERSIST: PERSIST_ONLY
- PRIVILEGES: none to read,
SYSTEM_VARIABLE_ADMIN
andPERSIST_RO_VARIABLES_ADMIN
to write - COMMAND LINE: Yes
- DESCRIPTION: "If set, slave is not autostarted."
- OBSERVABILITY: as a user, execute
SELECT @@skip_slave_status
to access the current value of the variable
Performance
No impact in performance is expected.
Storage engines
No special concerns storage engines.
Security context
No special concerns regarding security since the already existent
infra-structure and privileges used to protected the changes of a read-only
persistable-only global variable will be applied to skip_slave_start
,
more specifically, SYSTEM_VARIABLES_ADMIN
and
PERSIST_RO_VARIABLES_ADMIN
are needed to persist a read-only global
static variable.
Upgrade/Downgrade
No special concerns regarding upgrade/downgrade.
Cross-version replication
No special concerns regarding cross-version replication since variable changes aren't replicated.
Observability
The variable state will be available and observable through the following SQL statements:
SELECT @@skip_slave_start
SELECT variable_value FROM performance_schema.global_variables WHERE variable_name = 'skip_slave_start'
SELECT variable_value FROM performance_schema.persisted_variables WHERE variable_name = 'skip_slave_start'
() () Only available ifSET PERSIST_ONLY
has been executed forskip_slave_start
Deployment / installation
No changes to deployment or installation processes.
Protocol
No foreseeable changes to the MySQL protocol.
API AND DATA STRUCTURES
Changes in the current API
Prior to this work, skip_slave_start
was a command line parameter, with
an associated global internal variable that stores the current parameter
value.
Such infra-structure will be kept and the implementation will deal only
with moving the variable from the command line long-option infra-structure
to the sys_var
infra-structure:
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index e06e52e29751e029614b3f72b97c7af8e8bf2aa6..88e9117a1f1b4955085da065ef830f65da7f48a9 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -8387,9 +8387,6 @@ struct my_option my_long_options[] = {
{"skip-new", OPT_SKIP_NEW, "Don't use new, possibly wrong routines.",
nullptr, nullptr, nullptr, GET_NO_ARG, NO_ARG, 0, 0, 0, nullptr, 0,
nullptr},
- {"skip-slave-start", 0, "If set, slave is not autostarted.",
- &opt_skip_slave_start, &opt_skip_slave_start, nullptr, GET_BOOL, NO_ARG, 0,
- 0, 0, nullptr, 0, nullptr},
{"skip-stack-trace", OPT_SKIP_STACK_TRACE,
"Don't print a stack trace on failure.", nullptr, nullptr, nullptr,
GET_NO_ARG, NO_ARG, 0, 0, 0, nullptr, 0, nullptr},
diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc
index 242e649f34cfdb7edd26f446d8b32cb9c3385b96..93a7dc8301c6e52f13d971b99fe1b82e44fb894d 100644
--- a/sql/sys_vars.cc
+++ b/sql/sys_vars.cc
@@ -7060,3 +7060,9 @@ static Sys_var_bool Sys_replication_sender_observe_commit_only(
GLOBAL_VAR(opt_replication_sender_observe_commit_only), CMD_LINE(OPT_ARG),
DEFAULT(false), NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(nullptr),
ON_UPDATE(nullptr));
+
+static Sys_var_bool Sys_skip_slave_start(
+ "skip_slave_start", "If set, slave is not autostarted.",
+ READ_ONLY GLOBAL_VAR(opt_skip_slave_start), CMD_LINE(OPT_ARG),
+ DEFAULT(false), NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(nullptr),
+ ON_UPDATE(nullptr));
IMPLEMENTATION PLAN
- Step#1: move the variable from the long-options to the system
variable infra-structure; add the proper test script to the
sys_vars
suite.