If commit at some of the nodes failed, coordinator should rollback prepared transaction at all nodes.
Not always. If COMMIT PREPARED fails at some of the nodes but succeeds on others, the transaction is already partially acknowledged as committed in the cluster. Hence it makes more sense for the coordinator to commit transactions on the remaining nodes. Before issuing any COMMIT PREPARED queries, I guess that's fine to rollback the transactions on all nodes though.
We will get inconsistency if transaction is committed on some subset of nodes involved in transaction. Assume bank debit-credit example. If some distributed transaction transfers money from the account at one node to the account and another node, then committing transaction just at one node cause incorrect total balance. The main goal of DTM is to preserve ACID semantic for distributed transaction, so either transaction is committed at all nodes, either it is not committed at all.
Agreed.
COMMIT PREPARED is a pretty thin layer; the work is all done in the PREPARE. With a DTM, the main commit itself is done once only in the DTM, so all the COMMIT PREPARED would do is release local node resources.
--
Simon Riggs http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services