Group Replication delivery message service

In the process of enhancing MySQL replication with new features for our users, we also improve the internals. A lot of work goes also to modernize the codebase and make it easier to maintain and obviously extend as well.

In MySQL 8.0.18, we have extended the set of internal services with a group replication  message passing service, therefore generalizing the communication framework for group replication. It allows other components than just the group replication plugin to engage the group communication layer.

So, how is the design ?

MySQL services allow the plugins to access functionality of server, this is the base of Group Replication delivery message service, please consult here to get more details about service design.

The Group Replication delivery message service is composed of two services:

  • to send messages using Group Replication communication mechanism
  • to receive and deliver to components that are subscribed to that message type

The messages types are identified by a tag mechanism, a string that shall not have the reserved prefix mysql_.

The service is agnostic of type and content of payload being transmitted , so encoding/decoding responsibility belongs to its sender/receiver.

When no receiver is registered there is no error from the service but in case of a receiver return error the member will leave the group, as Group Replication cannot guarantee consistency when one  member failed to process the message.

If the module using Group Replication delivery message service needs to communicate to all members of the group it needs to confirm all of them support it. If server has a previous version it will discard the unknown messages and won’t have send service available.

And an example

So lets imagine that we want to create an IRC between all members of Group
Replication, something simple just send a message and members ONLINE will
receive it.

The IRC module will use IRC as a tag to identify messages being transmitted.
Subscribers of the service will be able to filter the messages using the tag.

To send messages you have to acquire the send service and write the message,
for example send “Hello World !!” with tag “IRC.

Using pseudo code, this can be implemented as:

All members ONLINE on the group, even the member that sent the message, will
receive the message. Then, group replication will see the modules that are
subscribed and notify that there is a new message.

Using pseudo code, we need to define a function which will be called by service when a
message is received:

To print messages with tag “IRC” to error log we can:

And registry the function on the service:

When the service receive will verify the tag is the expected and use it.

Use it

If you are interested further into this topic or even developing your own extensions to  MySQL, you may find more information in the doxygen documentation here. Then play with the code itself, by downloading it from the usual place. Have fun!

3,648 total views, 62 views today

One thought on “Group Replication delivery message service

Leave a Reply