forked from facebook/mysql-5.6
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FB8-48: Option to run triggers on slave for row-based events (faceboo…
…k#946) (facebook#946) Summary: JIRA: https://jira.percona.com/browse/FB8-48 Reference Patch: facebook@8225c64 Reference Patch: facebook@f5466d6 Reference Patch: facebook@87e3650 Port the slave_run_triggers_for_rbr feature from mariadb 10.1.1. When using statement based replication slave executes the sql statments which runs the slave side triggers. Since in row based replication, slave applies the row events directly to the storage engine, triggers on the slave table are not executed. Add functionality to run triggers on slave side when executing row based events. The following triggers are invoked: * Update_row_event runs an UPDATE trigger * Delete_row_event runs a DELETE trigger * Write_row_event action depends on whether the operation will require foreign key checks: 1) when FK checks are not necessary, the operation will invoke a DELETE trigger if the record to be modified existed in the table. After that, an INSERT trigger will be invoked. 2) when FK checks are necessary, either an UPDATE or or a combination of DELETE and INSERT triggers will be invoked. slave_run_triggers_for_rbr option controls the feature. Default value is NO which don't invoke trigger for row-based events; Setting the option to YES will cause the SQL slave thread to invoke triggers for row based events; setting it to LOGGING will also cause the changes made by the triggers to be written into the binary log. There is a basic protection against triggers being invoked both on the master and slave. If the master modifies a table that has triggers, it will produce row-based binlog events with the "triggers were invoked for this event" flag. The slave will not invoke any triggers for flagged events. optionally disable binlogging while executing triggers Online schema change (OSC) creates triggers only on master side. Since RBR logs row changes made by triggers, sql_thread will hit errors due to missing tables on slaves. Add a session variable SQL_LOG_BIN_TRIGGERS to optionally disable binlogging for trigger statements so that RBR and OSC are fine with each other. disable_sql_log_bin_triggers flag is added in the TABLE_LIST struct to track tables that are opened during trigger execution. This flag is used to skip writing Table_map_log_events for such tables. With sql_log_bin_triggers enabled, the trigger changes which may be necessary for slave are not propagated. To avoid this, slave_run_triggers_for_rbr option must be enabled on slave. Pull Request resolved: facebook#946 Reviewed By: lloyd Differential Revision: D13972562 Pulled By: lth
- Loading branch information
1 parent
1a9517d
commit 60804c7
Showing
42 changed files
with
1,232 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
if (`select count(*) = 0 from performance_schema.session_variables where variable_name = 'slave_run_triggers_for_rbr'`) | ||
{ | ||
skip RBR triggers are not available; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.