2012-11-09 45 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_ *操作,操作是以半異步方式執行的。」半異步在這裏意味着什麼? –

相關問題