-
Notifications
You must be signed in to change notification settings - Fork 0
Remote Clone Flow
In remote clone, client and donor are separate instances communicating through network.
The clone plugin defines and uses a RPC protocol with several COM_
commands. The storage engine interface does not deal with them directly, the map to the same handlerton API as the local clone which does not use the RPC protocol.
- The client plugin establishes a regular MySQL protocol connection to the donor, then sends
COM_CLONE
MySQL protocol command to switch to the clone protocol. - The client plugin calls
clone_apply_begin(HA_CLONE_MODE_VERSION)
. The storage engine creates a locator that does not point to any snapshot but contains version negotiation information instead. - The client plugin sends
COM_INIT
to the donor with the locator payload. - The donor plugin calls
clone_begin(HA_CLONE_MODE_START)
. It checks the version information in the passed version locator. Then it creates a snapshot and prepares an actual clone locator. All subsequent flow uses this locator. - The donor plugin sends
COM_RES_LOCS
with the locators as the response to the previousCOM_INIT
. - The client plugin calls
clone_apply_begin(HA_CLONE_MODE_START)
.
- The client plugin sends
COM_EXECUTE
to the donor which asks to stream the data. - The donor plugin calls
clone_copy
(same as the local clone), whose output is then serialized into two responses:-
COM_RES_DATA_DESC
for metadata -
COM_RES_DATA
for the data itself
-
- The client plugin passes the two response payload to
clone_apply
, which is then handled the same as for the local clone, with the additional requirement that any application of the memory data is acknowledge by sendingCOM_ACK
to the donor.
- After donor completes sending all the data, the sends a
COM_RES_COMPLETE
packet. - The client plugin calls
clone_apply_end
. - The client plugin sends
COM_EXIT
to the donor. - The donor calls
clone_end
.
New threads are spawned by the plugin client-side. Each thread sends a COM_ATTACH
command to the donor, which makes the donor to start a new thread on the donor and call clone_init(HA_CLONE_MODE_ATTACH)
there. Then the threads go through the above sequence.
To initiate a restart, the client prepares a restart locator that has both the snapshot ID and the application state which describes what exactly has been applied in this clone session so far, and sends it to the donor with a COM_REINIT
command. To send the command, a new MySQL protocol session is created and COM_CLONE
is issued to switch the session to the clone mode.