Skip to content

Conversation

@andremralves
Copy link
Contributor

@andremralves andremralves commented Apr 2, 2024

  • The Jira issue number for this PR is: MDEV-33782

Description

Implement a new option for events, WRITE_TO_BINLOG_ENABLE. If this option is set, events will be replicated with Event:status = ENABLE, otherwise, the event status will be DISABLED. Thanks @andrelkin for the idea.

Here is a table showing some examples:

Sql command Event Status on Master Event Status on Slave
create event .. ENABLE .. Enabled Disabled
create event .. DISABLE .. Disabled Disabled
create event .. ENABLE WRITE_TO_BINLOG_ENABLE .. Enabled Enabled
create event .. DISABLE WRITE_TO_BINLOG_ENABLE .. Disabled Enabled

Previously, events were replicated with the SLAVESIDE_DISABLED status. With this patch they will be set either to DISABLED or ENABLED --if WRITE_TO_BINLOG_ENABLE is defined.

Release Notes

Implement a new option for events, WRITE_TO_BINLOG_ENABLE. If this option is set, events will be replicated with Event:status = ENABLE, otherwise, the event status will be DISABLED. Replicated events will not be set to SLAVESIDE_DISABLED anymore.

How can this PR be tested?

./mtr rpl.rpl_create_drop_event 

It can also be tested with manual tests setting up a replication.

Basing the PR against the correct MariaDB version

  • This is a new feature and the PR is based against the latest MariaDB development branch.
  • This is a bug fix and the PR is based against the earliest maintained branch in which the bug can be reproduced.

PR quality check

  • I checked the CODING_STANDARDS.md file and my PR conforms to this where appropriate.
  • For any trivial modifications to the PR, I am ok with the reviewer making the changes themselves.

@andremralves andremralves force-pushed the MDEV-33782 branch 3 times, most recently from 1b36c60 to 63c54e4 Compare April 3, 2024 03:11
Copy link
Contributor

@HugoWenTD HugoWenTD left a comment

Choose a reason for hiding this comment

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

In my opinion, DISABLE ON SLAVE and ENABLE ON SLAVE seem to suggest that they are specific options for the replica (formerly known as the slave) only. However, the existing DISABLE ON SLAVE command actually disables the feature on both the source (formerly known as the master) and the replica. MySQL actually has a bug report for it. https://bugs.mysql.com/bug.php?id=31643

On the other hand, if based on current behavior, new ENABLE ON SLAVE seems to do the right thing as the opposite to DISABLE ON SLAVE.


By the way, better to add some descriptions in the commit message for example why the change is needed.

Copy link
Contributor

@LinuxJedi LinuxJedi left a comment

Choose a reason for hiding this comment

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

Nice work!

It appears this is failing a test when embedded server is built, funcs_1.is_columns_mysql_embedded, could you please fix this too?

@andremralves
Copy link
Contributor Author

andremralves commented Apr 11, 2024

It appears this is failing a test when embedded server is built, funcs_1.is_columns_mysql_embedded, could you please fix this too?

I'm working on it.

Edit: It's fixed now

Copy link
Contributor

@LinuxJedi LinuxJedi left a comment

Choose a reason for hiding this comment

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

Many thanks for fixing that. I'll try to get someone from the replication team to give it the next stage of review.

@andrelkin andrelkin self-requested a review August 6, 2024 18:19
@andrelkin
Copy link
Contributor

@andremralves salute!
I started reviewing the top-level of this work, to have noticed something interesting I believe.
Please read on that on Jira and preferably reply on there too (that seems easier to engage the feature reporter).

Thanks for this work for far!

Andrei

sql/sql_yacc.yy Outdated
Lex->event_parse_data->status_changed= true;
$$= 1;
}
| ENABLE_SYM ON SLAVE
Copy link
Contributor

@andrelkin andrelkin Aug 9, 2024

Choose a reason for hiding this comment

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

Please read a discussion on Jira about how to express in SQL way the desired effect.

This patch does address the FR, but it complicates earlier dubious design decision still. As the FR requires to achieve on slave Event::status as ENABLE a straightforward way to help it is to encode such intent as a new option which would be merely for logging on master and unlogging on slave (that is slave should be able to deduce which of the binary status the replicated Event should be created with). That is it need not to expand Event::status, rather contrary.

We could even leave the current name of SLAVESIDE_ENABLED but not regard it the way it's done in the current patch.
Also consider WRITE_TO_BINLOG_ENABLE (somewhat this naming would follow an existing NO_WRITE_TO_BINLOG) instead.

When it's specified ...

sql/sql_yacc.yy Outdated
}
| ENABLE_SYM ON SLAVE
{
Lex->event_parse_data->status= Event_parse_data::SLAVESIDE_ENABLED;
Copy link
Contributor

@andrelkin andrelkin Aug 9, 2024

Choose a reason for hiding this comment

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

... status would be set on slave straight to ENABLE unless the event is CREATE-ed with DISABLE status.
Logics inside Event_parse_data::check_originator_id() would need some adjustment, which is to disable the event on slave

status= Event_parse_data::DISABLED

without the new logging option.

The status of event on any server then would flip between just two ENABLE and DISABLE.
I think the slave should preserve the new option in its binlog when one is configured on the slave.

Copy link
Contributor Author

@andremralves andremralves Feb 2, 2025

Choose a reason for hiding this comment

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

Hi @andrelkin, you also mentioned create event .. log_as [DISABLE|ENABLE] in Jira, which I believe have the same purpose of WRITE_TO_BINLOG_ENABLE, but the latter one is just a more polished idea, right?

So basically, if WRITE_TO_BINLOG_ENABLE is set we replicate as ENABLED otherwise DISABLED. I made a table to make it easier to visualize:

Options Master Status Slave Status
status: ENABLED Enabled Disabled
status: DISABLED Disabled Disabled
status: ENABLED + WRITE_TO_BINLOG_ENABLE Enabled Enabled
status: DISABLED + WRITE_TO_BINLOG_ENABLE Disabled Enabled

Now I see that Event:status would be reduced to only ENABLED/DISABLED, but what should we do to SLAVESIDE_DISABLED? Remove it? Change it's purpose?

Copy link
Contributor

Choose a reason for hiding this comment

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

the latter one is just a more polished idea, right?

Indeed, and more precisely the new option to the command's syntax does not force a new state.

SLAVESIDE_DISABLED? Remove it?

Correct.

Copy link
Contributor

Choose a reason for hiding this comment

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

Howdy @andremralves !

To make it clear your option's syntax - just a single word WRITE_TO_BINLOG_ENABLE looks fine to me.
The patch therefore only lacks SLAVESIDE_DISABLED removal.

Copy link
Contributor

@andrelkin andrelkin left a comment

Choose a reason for hiding this comment

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

Hello Andre!

Thanks for a good effort to satisfy to the feature request.
I am explaining why we could and should do it better though.

Specifically I think we should treat the new syntax as a sub-clause to control logging/unlogging.
Inevitably we would eradicate the old Event_parse_data::SLAVESIDE_DISABLED from Event::status.

I hope the measures will make sense for you as well.

Cheers,
Andrei

@andremralves
Copy link
Contributor Author

Hi Andrei,

Thanks for your feedback.

I will read more carefully the discussion on jira and then respond here and there.

@cvicentiu cvicentiu added the External Contribution All PRs from entities outside of MariaDB Foundation, Corporation, Codership agreements. label Nov 26, 2024
@andrelkin
Copy link
Contributor

andrelkin commented Jan 27, 2025

Salve @andremralves!

I wonder about your plan and timetable to complete this PR?
Could you please share with us if any help is needed for that.

Happy NY on few calendars :-)!

Andrei

@andremralves
Copy link
Contributor Author

Salve @andrelkin !

I got caught up with other things and honestly forgot about this issue—sorry for the delay! I’ll try to finish it over the weekend, and if I can’t, I’ll update you all on how I plan to proceed.

Thanks for checking in, and happy NY on those calendars too!

Cheers,
André

@CLAassistant
Copy link

CLAassistant commented Feb 3, 2025

CLA assistant check
All committers have signed the CLA.

@andremralves andremralves changed the base branch from 11.5 to main February 3, 2025 02:01
@andremralves andremralves changed the title MDEV-33782 Implement ENABLE ON SLAVE option for events MDEV-33782 Implement WRITE_TO_BINLOG_ENABLE option for events Feb 3, 2025
@andremralves andremralves force-pushed the MDEV-33782 branch 2 times, most recently from af5a058 to 072bb89 Compare February 3, 2025 04:44
@bnestere bnestere added the Replication Patches involved in replication label Mar 25, 2025
@bnestere
Copy link
Contributor

bnestere commented Apr 4, 2025

@andremralves, hi! It looks like @andrelkin made one final suggestion (link) to your patch before it is ready to go. Are you still planning on working on this?

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.

7 participants