Category: Software Preview

ReplicationFeatures/ScriptableReplication


Contents

[edit] SCRIPTABLE REPLICATION

Developed by the MySQL Replication Team.

Feature preview to add the ability to execute Lua scripts as part of the replication process.

[edit] Provides:

This feature provides the ability to execute Lua scripts at various stages of the replication process. Currently, it is only possible to investigate the events and filter them out, but more advanced abilities to manipulate the replication events or the replication stream (for example, by adding new events) will be added in the future.

[edit] Use case:


[edit] User interface:

The Lua code to be executed is placed in separate modules for the binary log and the relay log. Each module then define the functions that are executed whenever an event is seen. The module for the binary log is replication.binary_log and the module for the relay log is replication.relay_log.

Modules are searched for under either the /etc/mysql/ext directory or the basdir/ext directory. Modules are organized hieraracly so that the replication.binary_log module is in the ext/replication/binary_log.lua file and the replication.relay_log module is placed correspondingly.

Place any code that should be executed when writing events to or reading events from the binary log in the replication.binary_log module.

Before writing an event to the binary log or relay log, the corresponding before_write function is called with a userdata object representing the event as parameter. If the function returns a value convertible to true, the event will be skipped, otherwise, it will be written to the binary log or relay log respectively.

After having read an event from the binary log or relay log, the corresponding after_read function is called with a userdata object representing the event as a parameter. If the function returns a value convertible to true, the event will be discarded. Otherwise, it is processed furthr, i.e., either sent to the slave or applied to the database depending on the module.

A short example of a module definition for the binary log to filter out all query log events containing the word "windows" is:

   module(..., package.seeall)
   function after_read(event)
      local m = event.query
      if m then
         return string.match(m, "windows")
      else
         return false
      end
   end

[edit] References:

[edit] Downloads:

Retrieved from "http://forge.mysql.com/wiki/ReplicationFeatures/ScriptableReplication"

This page has been accessed 312 times. This page was last modified 19:09, 21 April 2008.

Find

Browse
MySQLForge
Main Page
Current events
Recent changes
Random page
Help
Edit
Edit this page
Editing help
This page
Discuss this page
Post a comment
Printable version
Context
Page history
What links here
Related changes
My pages
Special pages
New pages
File list
Statistics
Bug reports
More...