Skip to content
This repository was archived by the owner on Mar 26, 2020. It is now read-only.

Transaction framework

Kaushal M edited this page Dec 1, 2015 · 8 revisions

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,

  1. actions will only be performed where required, instead of being done across the whole cluster
  2. final committing into the store will only be done by the node where the transaction was initiated, instead of being done on all nodes.

Base transaction

A basic transaction will provide the transaction framework with two bits of information,

  1. a list of nodes to run the transaction on
  2. 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

Common transaction template

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

  1. a list of nodes to run the transaction on
  2. an object withing the GD2 store to obtain a lock on
  3. a staging function, which checks is the node can perform the transaction
  4. a perform function, which performs the transaction action on the node
  5. a rollback function, to undo changes done by the commit function
  6. a store function to save results if required in to the store

When following the common template, a transaction will occur as follows.

  1. the transaction framework verifies all listed nodes are online
  2. the initiator node obtains a lock on the specified object
  3. the staging function is run on the listed nodes to verify if the transaction can happen
  4. the perform function is run on the listed nodes to actually perform the operation
  5. the store function is run on the initiator to store results
  6. 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.

Clone this wiki locally