January 16, 2011

2PC(two phase distributed commit)

Q: What is 2PC(two phase distributed Commit)

Ans: Peroming a distributed transaction is similar to a local transaction.

    Update local_table set x=10;
    Update remote_table@another_database set y=20;
    commit;

    Oracle will either commit in both databases  or nither, it uses atwo-pahse distributed commit(2PC) protocol to do this. Two-Phase commit is a transaction protocol designed for the complications that rise with distributed resoure manager. with a two-phase commit protocol, the distributed  transaction manager employs acordinator to manage the individual resource managers.

The commit process proceeds as follows:

  Phase 1:
        Each participating resource manager  coordinates  local operations and forces all log records out:
        If sucessful, responds "ok"
        If unsucessful, either allow a time-out or respond "oops"

  Phase 2:
       If all participants respond "ok"
             Coordinator instructs participatnig resource  manages to "COMMIT"
             Participants complete  operation writing the log record for the commit
      Otherwise:
              Coordinator instruts participating resource manager to "ROLLBACK"
              Participants complete their  respective local undos

No comments:

Post a Comment