Skip to content

MDEV-7394 : Making slave_skip_errors writable at runtime when slave is stopped #4634

Open
Mahmoud-kh1 wants to merge 1 commit into
MariaDB:mainfrom
Mahmoud-kh1:dynamic-slave-skip-error
Open

MDEV-7394 : Making slave_skip_errors writable at runtime when slave is stopped #4634
Mahmoud-kh1 wants to merge 1 commit into
MariaDB:mainfrom
Mahmoud-kh1:dynamic-slave-skip-error

Conversation

@Mahmoud-kh1

@Mahmoud-kh1 Mahmoud-kh1 commented Feb 8, 2026

Copy link
Copy Markdown
Contributor

Now we can update slave_skip_errors at runtime when slaves stopped

  • This feature makes the slave_skip_errors system variable dynamic allowing it
    to be changed at runtime when the replication slave is stopped.
  • Previously slave_skip_errors was read only at runtime and required a
    server restart to be changed.
  • Runtime updates are now validated and safely rejected when the slave is
    running preventing inconsistent replication state.

Key Changes

  • Split init_slave_skip_errors() into a bitmap-init phase (init_slave_skip_errors_bitmap()) and the existing make_slave_skip_errors_printable()
  • Added ON_CHECK handler to verify that updates are only allowed while the
    slave is stopped.
  • Added ON_UPDATE handler to reinitialize the internal skip error state
    when the variable is changed.
  • Added an rpl mtr test that verifies slave_skip_errors can be changed
    dynamically when the slave is stopped and verified that updates are rejected while the slave is running.

behavior now is like that :
test slave2

Feature :
MDEV-7394

@CLAassistant

CLAassistant commented Feb 8, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@Mahmoud-kh1
Mahmoud-kh1 force-pushed the dynamic-slave-skip-error branch 6 times, most recently from 87dbe8f to 3fa1017 Compare February 9, 2026 07:34
@gkodinov gkodinov added the External Contribution All PRs from entities outside of MariaDB Foundation, Corporation, Codership agreements. label Feb 9, 2026

@gkodinov gkodinov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is a preliminary review. I'd like to request changes mostly because there are tests that need to be re-recorded (and possibly fixed too).

The rest of the comments are just my own limited take on the change. Feel free to ignore and leave for the final review.

Comment thread sql/slave.cc Outdated
Comment thread sql/slave.cc Outdated
Comment thread sql/slave.cc Outdated
Comment thread sql/slave.cc Outdated
Comment thread mysql-test/suite/rpl/t/rpl_skip_error_dynamic.test Outdated
Comment thread sql/slave.cc Outdated
@grooverdan

Copy link
Copy Markdown
Member

Thank you so much for implementing my 11 year old bug report. I'd be very grateful if you stick through the review process on this. There's a lot to keep correct in the server to implement this change.

@Mahmoud-kh1
Mahmoud-kh1 force-pushed the dynamic-slave-skip-error branch from 3fa1017 to 440eec2 Compare February 12, 2026 12:41

@gkodinov gkodinov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please just fix the spacing issues. The rest is pretty much as one expects it to be. Aside from some polishing. Once the space changes are gone I will do another round and approve it.

Comment thread sql/slave.cc Outdated
Comment thread sql/slave.cc Outdated
Comment thread sql/slave.cc Outdated
Comment thread sql/slave.cc
Comment thread sql/slave.cc Outdated
Comment thread sql/slave.cc Outdated
Comment thread sql/slave.cc Outdated
Comment thread sql/slave.cc
Comment thread sql/slave.cc Outdated
Comment thread sql/slave.cc Outdated
Comment thread sql/slave.cc
Comment thread sql/slave.cc Outdated
Comment thread sql/slave.cc
@Mahmoud-kh1
Mahmoud-kh1 force-pushed the dynamic-slave-skip-error branch 7 times, most recently from b28dbed to 4b94518 Compare February 19, 2026 14:59
@Mahmoud-kh1
Mahmoud-kh1 requested a review from gkodinov February 20, 2026 11:42

@gkodinov gkodinov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please also address the buildbot failure. It seems related.

Comment thread mysql-test/suite/sys_vars/t/slave_skip_errors_basic.test Outdated
Comment thread sql/slave.cc Outdated
@Mahmoud-kh1
Mahmoud-kh1 force-pushed the dynamic-slave-skip-error branch 3 times, most recently from d21fd5b to 5af34c9 Compare February 20, 2026 14:07
@Mahmoud-kh1
Mahmoud-kh1 requested a review from gkodinov February 20, 2026 15:46
@Mahmoud-kh1
Mahmoud-kh1 force-pushed the dynamic-slave-skip-error branch 3 times, most recently from b294419 to 450161b Compare February 21, 2026 14:46
@Mahmoud-kh1
Mahmoud-kh1 force-pushed the dynamic-slave-skip-error branch 2 times, most recently from 861e1ca to eb834f6 Compare March 21, 2026 06:10
Comment thread sql/slave.cc Outdated
DBUG_RETURN(1);
}
my_free(opt_slave_skip_errors);
opt_slave_skip_errors= temp;

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.

Ahh okay I see. I'm pretty sure the current way you have it also leaks, as the memory used by Sys_var_charptr is pre-allocated, but the underlying pointer for opt_slave_skip_errors is over-written, and thus the old sysvar string value still exists afterwards and is never cleaned up.

Without the PREALLOCATED flag, Sys_var_charptr will auto-cleanup itself as a part of ::cleanup(). As opt_slave_skip_errors manually handles its own memory/pointer, this cleanup function should be called manually to ensure the state is correct.

What that would then look like is the logic within init_slave_skip_errors() should be split into two functions. First is the bitmap initialization from opt_slave_skip_errors->slave_error_mask, and second (which is already split) is make_slave_skip_errors_printable(). The mysqld use-case of init_slave_skip_errors doesn't need to free its opt_slave_skip_errors in-between these steps, but the sys_var update case does (I think, please verify that).

The way I see it then, is your new update_slave_skip_errors() function should manually call:

bool update_slave_skip_errors(sys_var *self, THD *thd, enum_var_type type):
  new_function_for_phase_1();
  self->cleanup();
  make_slave_skip_errors_printable();

and make_slave_skip_errors_printable() should be reverted to override opt_slave_skip_errors again.

What do you think?

--let $slave_sql_errno= 1062
--source include/wait_for_slave_sql_error.inc

SET GLOBAL slave_skip_errors = "1062";

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.

Given the nature of slave_skip_errors output re-ordering its input numbers, I think it would be good to add another test case with multiple error numbers input as out-of-order, and then their output shown as in-order.

@Mahmoud-kh1
Mahmoud-kh1 force-pushed the dynamic-slave-skip-error branch 6 times, most recently from 72de654 to 6b0dd99 Compare April 10, 2026 16:49

@gkodinov gkodinov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please keep a single commit in your PR. Now you have 4. And need to squash them. Otherwise, LGTM.

Comment thread sql/sys_vars.cc Outdated

@bnestere bnestere left a comment

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.

Hi @Mahmoud-kh1 !

This is very close now, thanks for your continued work! See my last couple notes.

The next round of review should be final, so please now squash all your commits together. In your git commit message, the convention for a maximum line width is 72 characters, please follow that. Please also add at the end of your message your reviewers:

Reviewed-by: Brandon Nesterenko <brandon.nesterenko@mariadb.com>
Reviewed-by: Georgi Kodinov <joro@mariadb.org>

Comment thread sql/sys_vars.cc Outdated
self->cleanup();
make_slave_skip_errors_printable();
}
}

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.

Many of the lines in this file have whitespace at the end. Please look at your changes with git show to see this, and remove lines with such whitespace.

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.

This is still relevant

Comment thread sql/sys_vars.cc Outdated
}
else
{
self->cleanup();

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 a comment explaining why we need to manually call self->cleanup()

@Mahmoud-kh1
Mahmoud-kh1 force-pushed the dynamic-slave-skip-error branch from 6b0dd99 to 0f22d26 Compare May 12, 2026 14:01
@Mahmoud-kh1
Mahmoud-kh1 requested a review from bnestere May 12, 2026 14:43

@bnestere bnestere left a comment

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.

Hi @Mahmoud-kh1 ! The excess whitespace comment is still relevant. That's my last note. Thanks for the PR review reminder :)

Comment thread sql/sys_vars.cc Outdated
self->cleanup();
make_slave_skip_errors_printable();
}
}

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.

This is still relevant

Allow slave_skip_errors to be changed at runtime when the
slave is stopped. Previously it was read-only.

Split init_slave_skip_errors() into a bitmap-init phase
(init_slave_skip_errors_bitmap()) and the existing
make_slave_skip_errors_printable(). Added check function
check_slave_skip_errors() that rejects changes while the
slave is running, and update function update_slave_skip_errors()
that rebuilds the bitmap and printable string on SET GLOBAL.

The update callback calls self->cleanup() between the two
phases to free the heap string allocated by global_update()
before the pointer is overwritten with the static
slave_skip_error_names[] buffer.

Added test rpl.rpl_slave_skip_errors_writable.

Reviewed-by: Brandon Nesterenko <brandon.nesterenko@mariadb.com>
Reviewed-by: Georgi Kodinov <joro@mariadb.org>
@Mahmoud-kh1
Mahmoud-kh1 force-pushed the dynamic-slave-skip-error branch from 0f22d26 to 5a330df Compare June 2, 2026 08:03
@Mahmoud-kh1
Mahmoud-kh1 requested a review from bnestere June 2, 2026 08:06

@gkodinov gkodinov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM. Please keep working with Brandon.

@bnestere bnestere left a comment

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.

Approved for the 13.1 preview, but slave_skip_errors_writable.test still has bad white space. It'll need to be fixed before the RC release (planned for July 28).

To explain our release process, the first public release we do is a preview release, which is when our testers do QA testing for new features. For 13.1, this is from when the preview release is assembled (probably in the next few days) through July 28. If our testers find any issues with this feature in this time, they must be fixed by July 28 to qualify for the RC release. Will you be generally available in this time to fix any possible issues?

Thanks for your continued work on this patch, @Mahmoud-kh1 !

@gkodinov gkodinov assigned elenst and unassigned bnestere Jun 11, 2026
@elenst elenst assigned mariadb-SusilBehera and unassigned elenst Jun 11, 2026
@knielsen

knielsen commented Jun 24, 2026 via email

Copy link
Copy Markdown
Member

@knielsen knielsen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

See mail comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

External Contribution All PRs from entities outside of MariaDB Foundation, Corporation, Codership agreements. Replication Patches involved in replication

Development

Successfully merging this pull request may close these issues.

8 participants