Repository navigation
MDEV-36841 Warn when SET slave_net_timeout drops below master_heartbeat_period - #4845
tonychen2001 wants to merge 1 commit into
Conversation
gkodinov
left a comment
There was a problem hiding this comment.
Thank you for your contribution! This is a preliminary review.
LGTM, but please fix the test failures.
5a12245 to
84ea4fc
Compare
gkodinov
left a comment
There was a problem hiding this comment.
LGTM. Please stand by for the final review.
bnestere
left a comment
There was a problem hiding this comment.
Thank you for your contribution, @tonychen2001 !
I've left a couple notes.
| VALID_RANGE(1, LONG_TIMEOUT), DEFAULT(SLAVE_NET_TIMEOUT), BLOCK_SIZE(1)); | ||
| VALID_RANGE(1, LONG_TIMEOUT), DEFAULT(SLAVE_NET_TIMEOUT), BLOCK_SIZE(1), | ||
| NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0), | ||
| ON_UPDATE(fix_slave_net_timeout)); |
There was a problem hiding this comment.
fix_slave_net_timeout() doesn't actually change any values does it? It looks like it only validates. I think in such case ON_UPDATE() isn't needed and it can just be done as part of ON_CHECK() and the function name should be changed to replace the fix_ prefix with something more appropriate (like check_).
The pattern for max_allowed_packet can be followed here as well as for my previous comment about changing the error to use.
There was a problem hiding this comment.
Updated to ON_CHECK().
| CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_PORT, MASTER_USER='root', MASTER_CONNECT_RETRY=20, MASTER_HEARTBEAT_PERIOD=40; | ||
| SET @@global.slave_net_timeout=20; | ||
| Warnings: | ||
| Warning 1704 The requested value for the heartbeat period exceeds the value of `slave_net_timeout' seconds. A sensible value for the period should be less than the timeout |
There was a problem hiding this comment.
This reads like the wrong error message. "The requested value for the heartbeat period exceeds..." makes it seem like we are trying to changed the heartbeat period, but it is the slave_net_timeout variable being changed. Perhaps WARN_OPTION_BELOW_LIMIT would be more appropriate here, as it doesn't imply which value is being set (alternatively you can add WARN_OPTION_ABOVE_LIMIT 🤷).
There was a problem hiding this comment.
Yes, I agree.
In regards to the warning, when using WARN_OPTION_BELOW_LIMIT (or even introducing WARN_OPTION_ABOVE_LIMIT) the error message would look like: The value of 'slave_net_timeout' should be no less than the value of 'master_heartbeat_period'.
A few thoughts related to this thread with Joro above is that when a user modifies the slave_net_timeout system variable, there could be multiple replication channels that have a master heartbeat period higher than the value of slave_net_timeout and it wouldn't be clear to the user which replication channels are problematic.
I think a clearer error message should contain the specific replication channels that have a problematic heartbeat period with respect to the new slave_net_timeout value.
What do you think about introducing a specific error message (e.g. ER_SLAVE_HEARTBEAT_PERIOD_ABOVE_TIMEOUT) that names the affected connection and have it emit a warning per replication connection with a problematic configuration:
Warning XXXX The heartbeat period for replication connection '' exceeds the value of 'slave_net_timeout'. A sensible value for the period should be less than the timeout.
Warning XXXX The heartbeat period for replication connection 'connection2' exceeds the value of 'slave_net_timeout'. A sensible value for the period should be less than the timeout.
There was a problem hiding this comment.
I agree that it would be good to call out the connection name. Though I think the message should be generalized to reporting on a parameterizable misconfiguration for a replication channel. Perhaps ER_OPERATION_INVALIDATES_CONFIGURED_SLAVE
With some message like
"This operation leaves replication connection '%s' with an invalid configuration: %s"
There was a problem hiding this comment.
Thank you for the feedback, I have added a parameterized general warning message which will read like:
Warning 4257 This operation leaves replication connection '' with an invalid configuration: the heartbeat period (4.000 seconds) exceeds the requested slave_net_timeout (3 seconds); a sensible value for the period should be less than the timeout
8389993 to
1678744
Compare
bnestere
left a comment
There was a problem hiding this comment.
Thanks @tonychen2001 , this looks good.
Though please rebase to the main branch, rather than 12.3, as it adds a new warning.
Sorry for such a slow turn-around on the review :(
1678744 to
b354b77
Compare
|
Thank you @bnestere , I've updated the target to |
There was a problem hiding this comment.
There seems to be compilation failure (see below). Can you please attend to the buildbot failures?
/home/buildbot/aarch64-debian-11/build/sql/sys_vars.cc: In function ‘bool check_slave_net_timeout(sys_var*, THD*, set_var*)’:
/home/buildbot/aarch64-debian-11/build/sql/sys_vars.cc:6169:11: error: invalid cast from type ‘Master_info_file::Heartbeat_period_value’ to type ‘uint32_t’ {aka ‘unsigned int’}
6169 | (uint32_t) mi->master_heartbeat_period <= timeout * 1000ULL)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/buildbot/aarch64-debian-11/build/sql/sys_vars.cc:6178:28: error: invalid cast from type ‘Master_info_file::Heartbeat_period_value’ to type ‘uint32_t’ {aka ‘unsigned int’}
6178 | (double) (uint32_t) mi->master_heartbeat_period / 1000,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
make[2]: *** [sql/CMakeFiles/sql.dir/build.make:2166: sql/CMakeFiles/sql.dir/sys_vars.cc.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [CMakeFiles/Makefile2:11692: sql/CMakeFiles/sql.dir/all] Error 2
make: *** [Makefile:182: all] Error 2
When CHANGE MASTER sets master_heartbeat_period to a value greater than @@GLOBAL.slave_net_timeout, a ER_SLAVE_HEARTBEAT_VALUE_OUT_OF_RANGE_MAX warning is emitted. However, the reverse scenario, lowering slave_net_timeout below an existing master_heartbeat_period, produced no warning. Add an on_check callback for slave_net_timeout that iterates all Master_info entries and warns if any heartbeat period exceeds the requested timeout. Connections that are not configured are skipped. A DEFAULT heartbeat period is skipped unless --master-heartbeat-period was given at startup: without it the period follows slave_net_timeout/2 and can never exceed the timeout, but with it the period is a fixed value and is checked like an explicit one. The warning is reported with a new, generalized error ER_OPERATION_INVALIDATES_CONFIGURED_SLAVE, which names the affected replication connection and carries a parameterized description of the misconfiguration. Naming the connection matters for multi-source: when several connections exceed the new timeout, the user can see exactly which ones are problematic. One warning is emitted per affected connection. Add a multi_source test, run with --master-heartbeat-period=30, that configures two named connections with explicit heartbeat periods above the timeout and a third left at DEFAULT, and verifies a distinct warning is emitted for each. All new code of the whole pull request, including one or several files that are either new files or modified ones, are contributed under the BSD-new license. I am contributing on behalf of my employer Amazon Web Services, Inc.
b354b77 to
a33f966
Compare
Description
When CHANGE MASTER sets master_heartbeat_period to a value greater than
@@GLOBAL.slave_net_timeout, aER_SLAVE_HEARTBEAT_VALUE_OUT_OF_RANGE_MAXwarning is emitted. However, the reverse scenario, lowering
slave_net_timeoutbelow an existingmaster_heartbeat_period, producedno warning.
Add an on_update callback for
slave_net_timeoutthat iterates allMaster_info entries and warns if any resolved heartbeat period exceeds
the new timeout value.
Release Notes
N/A
How can this PR be tested?
The MTRs
rpl.rpl_heartbeat_basicandrpl.rpl_heartbeathave been updated.Basing the PR against the correct MariaDB version
Copyright
All new code of the whole pull request, including one or several files that are either new files or modified ones, are contributed under the BSD-new license. I am contributing on behalf of my employer Amazon Web Services, Inc.