I find many readings that say 2PC is safe, which means it will either commit a transaction or rollback. More specifically, [If one commits, no one aborts; If one aborts, no one commits]. (http://www0.cs.ucl.ac.uk/staff/B.Karp/gz03/f2010/gz03-lecture6-2PC.pdf)
From Wikipedia, I know in commit phase, all processes will do the following things:
I wonder if in stage 1, the coordinator fails after it sent a message to several participants, which means some participants will receive the commit message while others will not. Then those who received will commit while others will still be blocked. So I think 2PC does not ensure safety here?
As the article from Wikipedia says:
If the coordinator fails permanently, some participants will never resolve their transactions: After a participant has sent an agreement message to the coordinator, it will block until a commit or rollback is received.
Key word here is “permanently”. In your first link 2PC algorithm is also marked safe only for controller restarts not permanent dead.
So 2PC is safe while its components can interact (even with restarts, connection losses and other temporary problems).