Sunday 1 January 2012

What is a Two phase commit 2PC in teradata?

Two phase Commit comes to picture when there are multiple database systems involved in a transaction .
Example : Teradata and DB2.
Assume a transaction that requires inserts into tables each in Teradata and DB2. If is fails in any of the database systems then it should not get committed in the other Db as well.This is where 2PC is used.

In 2PC one system will act as a coordinator while other will act is as participants.
When a transaction occurs requests are sent to each of the participants.
Depending upon whether each participant is able to commit changes, it votes to the coordinator.
Each participant will check for constraints, access violations etc and then will vote its status.
Even if one participant is not able to commit the changes then the transaction will be rolled back from each of the Database systems.

Only when each participant gives a OK vote transaction will not get commited.
This is how 2PC works.

The duration between participant voting its status and coordinator confirming the commit, the participant is said to be in doubt.

No comments:

Post a Comment