Question about XADisk's transaction log

58 views
Skip to first unread message

nzjavad...@gmail.com

unread,
Feb 14, 2015, 7:34:16 PM2/14/15
to xad...@googlegroups.com
Hi Nitin,

I've been looking at the source code of XADisk, just curious about its recovery mechanism. 

How is the ACID of transaction log is guaranteed? It seems it just uses FileChannel.write to write out the transactions, so if the system
crashes while writing those transactions, how will they get recovered? Furthermore, if a transaction log is corrupted due to system crash, 
will it also affect changes that are made to files - as it seems rollback/commit depends on the transaction log?


Thanks

Nitin Verma

unread,
Feb 15, 2015, 2:38:57 AM2/15/15
to xad...@googlegroups.com, nzjavad...@gmail.com
Hi,

During recovery, only those transactions are considered for committing which have written "commit" log but no "completion" log. During a transaction, a commit log is written only after all operation logs for that transaction are written and "force"d (using FileChannel.force api).

For transactions which are already complete, that is, their "completion" log is persisted, the recovery process does not matter as it won't be picking those transaction for commit/rollback.

I hope it answers your questions.

Thanks,
Nitin

Nitin Verma

unread,
Feb 15, 2015, 2:42:42 AM2/15/15
to xad...@googlegroups.com, nzjavad...@gmail.com
Also, the "commit" log is written just before most of the io operations are actually performed. And "completion" log is written when all these operations are done.

nzjavad...@gmail.com

unread,
Feb 16, 2015, 3:53:56 AM2/16/15
to xad...@googlegroups.com, nzjavad...@gmail.com
Hi Nitin,

Thanks for the answer, so presumably there is logic to detect "completion log"s validity and if it found to be partial,  it will just roll it back since if all operation logs must have been persisted if partial completion log presents?

 and if a "operation log" is found to be partial, I guess it would just ignore it - presumably the operation log is written and forced before each action is completed so if operation log is partial it means that action hasn't been done yet?

在 2015年2月15日星期日 UTC+13下午8:42:42,Nitin Verma写道:

Nitin Verma

unread,
Feb 18, 2015, 12:27:12 PM2/18/15
to xad...@googlegroups.com, nzjavad...@gmail.com
Hi,

You may look at org\xadisk\filesystem\workers\CrashRecoveryWorker.java, method findInCompleteTransactions. If an EOF is encountered while reading a log, we just stop collecting further information from that log file.

The presence of "operation" log itself is not utilized to commit or rollback a transaction during recovery. It is decided based on some kinds of commit/rollback begin, commit/rollback complete logs.

Thanks,
Nitin

Reply all
Reply to author
Forward
0 new messages