-
Notifications
You must be signed in to change notification settings - Fork 82
Transaction framework
The transaction framework will ensure that a given set of actions will be performed in order, one after another, on the required peers of the cluster.
The new transaction framework will be built around the central store. The new transaction framework will have 2 major differences to the existing frameworks,
- actions will only be performed where required, instead of being done across the whole cluster
- final committing into the store will only be done by the node where the transaction was initiated, instead of being done on all nodes.
A basic transaction will provide the transaction framework with two bits of information,
- a list of nodes to run the transaction on
- a set of steps/actions to be run
Given this information, the GD2 transaction framework will,
- verify if all the listed nodes are online
- run each step on all of the nodes, before proceeding to the next step
- finally commit any cluster data changes into the store from the leader
Any user is free to create free-form transactions by providing their own set of steps. To make it easier to quickly create simple transactions, a common transaction template will be provided.
The common transaction template will be based on the existing four step transaction algorithm being used. The template requires users to provide the following information
- a list of nodes to run the transaction on
- an object withing the GD2 store to obtain a lock on
- a staging function, which checks is the node can perform the transaction
- a perform function, which performs the transaction action on the node
- a rollback function, to undo changes done by the commit function
- a store function to save results if required in to the store
When following the common template, a transaction will occur as follows.
- the transaction framework verifies all listed nodes are online
- the initiator node obtains a lock on the specified object
- the staging function is run on the listed nodes to verify if the transaction can happen
- the perform function is run on the listed nodes to actually perform the operation
- the store function is run on the initiator to store results
- the initiator node unlocks the locked object
If any of the above fail (except unlock) fail, the transaction is aborted. If 1 or 2 fail, the transaction is aborted immediately. If 3 fails, unlock is done and transaction is aborted. If 4 or 5 fail, the rollback function is run on all nodes and followed by unlocking and the transaction is aborted.