Two Phase Commit and Replication

85 views
Skip to first unread message

PHeinze

unread,
Mar 13, 2012, 2:06:02 PM3/13/12
to mongod...@googlegroups.com
Hi,

I'm curious about the fact that when I use Two Phase Commit (2PC) if I can still use Replication right out of mongodb?

Would I simply replicate my primary Collections (Business Objects) and Transaction Collections. And on the secondaries I have those Transaction performing Threads as well? I think those would become only active when the primary fails and secondary becomes the new primary, is this right?

Or should I stuck with my own replication at all? How does 2PC look when even sharding comes into play?

Thank you

A. Jesse Jiryu Davis

unread,
Mar 15, 2012, 1:59:33 PM3/15/12
to mongod...@googlegroups.com
Hi, you can use replication with the technique outlined in the 2-phase commit document. Secondaries in a replica set are eventually consistent with the primary.

You can use slaveOk or ReadPreference in your MongoDB driver to choose whether to read from secondaries or the primary. If you want to ensure that you are reading the transaction you just committed, then read from the primary, and make sure you're setting the safe=True flag on all inserts and updates.

The 2-phase commit technique will work the same in a sharded environment as non-sharded.
Reply all
Reply to author
Forward
0 new messages