Tuesday, July 18, 2006

Why undo the log twice is good

I learned it the hard way!
Today I discovered why in the TransactionManager.C file, line 456 to 458, there is a section of code that undo the log again. It is because the following case:
1) P0 did a Store_XACT on a O state cache line, we would then have O->OM, so this cache line would be marked transactional but not put into the log yet.
2) Now I abort the transaction of P0 and the log is rolled back.
3) Po now get all the acks from other processor for its Store_XACT, O->OM transition. It has a new transition of All_acks, OM->MM. In this transition, the cache line is actually added to the log. If we don't rollback the log again, we have a problem. So, in the restore register part of the abort, we rollback transaction logs again.

No comments: