Somewhat obviously, they can be used to check the validity of a block of data such as a journal transaction.
显而易见,这种方式也可以被用来检查写入数据(比如日志事务)的有效性。
So if a transaction reached the end of the dosync block, and the STM sees that another transaction has finished since the current one started, then the current one will be rolled back and run again.
Clojure会确保在事务中间该值没有发生改变,因此,如果事务到达了dosync块的结尾,并且,STM可看到在当前事务启动以来有另一事务已经完成了,那么当前事务将回滚并再次运行。
A way to counter the journal corruption is to compute a checksum of the transaction log and write it as part of the commit block process.
对付该问题的一个办法就是,计算一个事务日志的校验和,并把它作为commit block过程的一部分写到日志中。
应用推荐