Tuesday 31 March 2015

Optimistic Partitioned Databases

The Partitioned Database Tutorial is now also updated for today's version of the distribution.
For comments on safety of these so-called "optimistic approaches", see my previous blog post.
Being optimistic does not mean skipping the three-phase commit!

Tuesday 24 March 2015

Optimistic transaction safety

Having just updated the Distributed Database tutorial for Pyrrho with all its three-phase commit stuff I thought it might be a good time to state once again that while Pyrrho uses optimistic concurrency control, it is totally transaction-safe. If you are using explicit transactions you can use the system "Log$" table to view the proposed changes for the current transaction. Each connection will have its own, and it is easy to see the they are isolated: the only entries with known positions are the ones that predated the start of the transaction.

Accordingly the transaction commit protocol is in 4 or 5 phases controlled by locks on the transaction log file (which in Pyrrho is the durable version of the database): 1. Verify the transaction does not conflict with anything written since the start of the transaction. 1.5 Lock the database and repeat this test. 2. Prepare the binary package to be written. 3. Write it to the disk file and unlock the database. 4. Now discard the local transaction and allow the client to see the database as it now is.
If multiple servers or databases are active then step 3 here requires three-phase commit during which time the proposed changes are written to temporary files. If all is well, these temporary files do not need to be read, and can be removed once all participants have acknowledged the commit request.