WL#12385: Turn binlog-row-event-max-size into a sysvar

Affects: Server-8.0   —   Status: Complete

EXECUTIVE SUMMARY
=================

This worklog makes the binlog-row-event-max-size CLI option into a
server read only variable. I.e., the CLI option is not going away,
it will remain and in addition to that there will be a read only
system variable that the user can read (and set persistently only)
through a regular SQL user session.

USER STORIES
============

As a MySQL DBA I want to be able to SET PERSIST_ONLY binlog_row_event_max_size
so that I can configure binlog_row_event_max_size in my instance for which
I do not have filesystem access to be changing my.cnf instead.

As a MySQL DBA I want to read the value of binlog_row_event_max_size through
an SQL interface - SHOW VARIABLES LIKE ... - because I don't have access to
the filesystem, so that I am able to do some troubleshooting myself.

SCOPE
=====

The scope of this worklog is to make this option a read-only variable as
well. This worklog does not make this option dynamically changeable. 

This work fits in the overall roadmap of making the server completely
configurable through a session, i.e., without requiring access to the
filesystem to configure a server instance.

REFERENCES
==========

- binlog-row-event-max-size value is not shown in SHOW VARIABLES
  https://bugs.mysql.com/bug.php?id=74728
FUNCTIONAL REQUIREMENTS
=======================

- The user SHALL be able to configure the system variable
  binlog-row-max-event-size using SET PERSIST_ONLY.

- The user SHALL get an ERROR (ER_INCORRECT_GLOBAL_LOCAL_VAR) if he
  tries to change the variable.

- The user SHALL get an ERROR (ER_INCORRECT_GLOBAL_LOCAL_VAR) if he
  tries to SET PERSIST it.

- The variable value SHALL be exposed through SHOW VARIABLES LIKE
  '%binlog_row_event_max_size%', performance_schema.session_variables,
  performance_schema.global_variables and
  performance_schema.persisted_variables.
SUMMARY OF THE APPROACH
=======================

In this worklog, we are just making turning an existing option into a
read-only system variable, so that one can configure it through SET
PERSIST_ONLY.

SECURITY CONTEXT
================

N/A

UPGRADE/DOWNGRADE and CROSS-VERSION REPLICATION
===============================================

No impact on cross-version replication.

On upgrade-downgrade users that keep logs of the output of SHOW
VARIABLES or other externalization infrastructures may be affected, if
they keep this output as a record of the configs. At the end of the
day, this will introduce a new variable in the output of such commads,
thus it may break existing automated scripts that users may have
created.

USER INTERFACE
==============

A new read-only global system variable will be introduced:

- new variable (which used to be a CLI option)

  NAME: binlog_row_event_max_size
  VALUES: [256, ULONG_MAX]
  DEFAULT: 8192
  SCOPE: GLOBAL
  REPLICATED: no
  DYNAMIC: No
  PERSIST: Yes (PERSIST_ONLY)

OBSERVABILITY
=============

The the new system variable is observable through the regular
performance_schema tables as well as the regular SHOW commands for
variables. 

Examples:

- SELECT * FROM performance_schema.global_variables WHERE
  variable_name LIKE '%binlog_row_event_max_size%';

- SELECT * FROM performance_schema.session_variables WHERE
  variable_name LIKE '%binlog_row_event_max_size%';

- SHOW VARIABLES LIKE 'binlog_row_event_max_size';

- SELECT * FROM performance_schema.variables_info WHERE variable_name
  LIKE 'binlog_row_event_max_size';

- SELECT * FROM performance_schema.persisted_variables WHERE
  variable_name LIKE 'binlog_row_event_max_size';

DEPLOYMENT and INSTALLATION
===========================

No changes.

PROTOCOL
========

No changes.

FAILURE MODEL SPECIFICATION
===========================

N/A
DESIGN IMPLEMENTATION STEPS
===========================

1. Remove the CLI option from mysqld.cc.

-    {"binlog-row-event-max-size", 0,
-     "The maximum size of a row-based binary log event in bytes. Rows will be "
-     "grouped into events smaller than this size if possible. "
-     "The value has to be a multiple of 256.",
-     &opt_binlog_rows_event_max_size, &opt_binlog_rows_event_max_size, 0,
-     GET_ULONG, REQUIRED_ARG,
-     /* def_value */ 8192, /* min_value */ 256, /* max_value */ ULONG_MAX,
-     /* sub_size */ 0, /* block_size */ 256,
-     /* app_type */ 0},

2. Add the a sysvar with the same CLI option name to sys_vars.cc.

+static Sys_var_ulong Sys_binlog_row_event_max_size(
+    "binlog_row_event_max_size",
+    "The maximum size of a row-based binary log event in bytes. Rows will be "
+    "grouped into events smaller than this size if possible. "
+    "The value has to be a multiple of 256.",
+    READ_ONLY GLOBAL_VAR(binlog_row_event_max_size), CMD_LINE(REQUIRED_ARG),
+    VALID_RANGE(256, ULONG_MAX), DEFAULT(8192), BLOCK_SIZE(256), NO_MUTEX_GUARD,
+    NOT_IN_BINLOG, ON_CHECK(NULL), ON_UPDATE(NULL));

3. Add a sys_var test case testing the new system var.