2012-11-09 44 views
3

一系列mnesia:dirty_命令在传递给mnesia:async_dirty()的函数中执行的命令与那些执行完全相同的事务之间有什么区别“生的”?“原始”脏操作和脏操作之间有什么区别:async_transaction

也就是说,有没有这样做有什么区别:

mnesia:dirty_write({table, Rec1}), 
mnesia:dirty_write({table, Rec1}), 
mnesia:dirty_write({table, Rec1}) 

F = fun() -> 
     mnesia:dirty_write({table, Rec1}), 
     mnesia:dirty_write({table, Rec1}), 
     mnesia:dirty_write({table, Rec1}) 
    end, 

    mnesia:async_dirty(F) 

感谢

回答

-1

让我们先引用用户指南上async_dirty方面:

 
By passing the same "fun" as argument to the function 
mnesia:async_dirty(Fun [, Args]) it will be performed in dirty context.
The function calls will be mapped to the corresponding dirty functions.
This will still involve logging, replication and subscriptions but there will be
no locking, local transaction storage or commit protocols involved. Checkpoint
retainers will be updated but will be updated "dirty". Thus, they will be updated
asynchronously. The functions will wait for the operation to be performed on one
node but not the others. If the table resides locally no waiting will occur.

您提供的两个选项将以相同的方式执行。但是,如果按照选项1执行fun中的脏功能,每个都是对mnesia的单独调用。使用async_dirty时,3个调用将被捆绑,并且mnesia只会等到本地节点上的3个完成返回。
但是,这两个行为在mnesia多节点集群中可能会有所不同。做一些测试:)

+0

你是什么意思“......这两个行为可能在多节点集群中有所不同”,你的意思是你不知道它是否会有所不同,你知道它会有所不同,但不要不知道怎么样,或者你知道但不告诉我? – Jr0

+0

我知道他们会有所不同,但不知道具体如何:) –

+0

Downvoted这是因为我有同样的问题,这个答案是不够的。如果您阅读async_dirty文档,它会说:“对于正常的mnesia:dirty_ *操作,操作是以半异步方式执行的。”半异步在这里意味着什么? –

相关问题