Working of Distributed Transactions
The working of Distributed Transactions is the same as that of simple transactions but the challenge is to implement them upon multiple databases. Due to the use of multiple nodes or database systems, there arises certain problems such as network failure, to maintain the availability of extra hardware servers and database servers. For a successful distributed transaction the available resources are coordinated by transaction managers.
Step 1: Application to Resource – Issues Distributed Transaction
The first step is to issue that distributed transaction. The application initiates the transaction by sending the request to the available resources. The request consists of details such as operations that are to be performed by each resource in the given transaction.
Step 2: Resource 1 to Resource 2 – Ask Resource 2 to Prepare to Commit
Once the resource receives the transaction request, resource 1 contacts resource 2 and asks resource 2 to prepare the commit. This step makes sure that both the available resources are able to perform the dedicated tasks and successfully complete the given transaction.
Step 3: Resource 2 to Resource 1 – Resource 2 Acknowledges Preparation
After the second step, Resource 2 receives the request from Resource 1, it prepares for the commit. Resource 2 makes a response to resource 1 with an acknowledgment and confirms that it is ready to go ahead with the allocated transaction.
Step 4: Resource 1 to Resource 2 – Ask Resource 2 to Commit
Once Resource 1 receives an acknowledgment from Resource 2, it sends a request to Resource 2 and provides an instruction to commit the transaction. This step makes sure that Resource 1 has completed its task in the given transaction and now it is ready for Resource 2 to finalize the operation.
Step 5: Resource 2 to Resource 1 – Resource 2 Acknowledges Commit
When Resource 2 receives the commit request from Resource 1, it provides Resource 1 with a response and makes an acknowledgment that it has successfully committed the transaction it was assigned to. This step ensures that Resource 2 has completed its task from the operation and makes sure that both the resources have synchronized their states.
Step 6: Resource 1 to Application – Receives Transaction Acknowledgement
Once Resource 1 receives an acknowledgment from Resource 2, Resource 1 then sends an acknowledgment of the transaction back to the application. This acknowledgment confirms that the transaction that was carried out among multiple resources has been completed successfully.
What is a Distributed Transaction?
A distributed transaction is defined as a group of operations that are to be performed across more than one database or data repository. The operations are performed by multiple nodes that are connected to a single network. The distributed transaction ensures ACID (Atomicity, Consistency, Isolation, Durability) properties and data integrity.
Contact Us