Does foreach iterate over uncommitted ledger? #3926
-
From the documentation of https://microsoft.github.io/CCF/release/1.x/build_apps/kv/kv_how_to.html |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
There is not a foreach equivalent to Note that using |
Beta Was this translation helpful? Give feedback.
-
@divneil-intel Those entries may not yet be committed by consensus (replicated on a majority of nodes), but this transaction will be applied in-order (ie - if it eventually commits, that implies that all the things it read are also committed, and if any of the transactions it depends on are rolled back, it is also rolled back). |
Beta Was this translation helpful? Give feedback.
-
Thanks @achamayou, @eddyashton for your replies. The explanation makes the usage scenarios clear. |
Beta Was this translation helpful? Give feedback.
foreach()
, likeget()
andput()
operates on the current read version, which may or may not be committed by consensus. It is guaranteed that if the read version is rolled back, the subsequent transaction containing theforeach
will also be rolled back. Or to put it another way, if the transaction containing theforeach
commits, then the read version it resolved to must have also committed.There is not a foreach equivalent to
get_globally_committed()
if that's what you mean, that would let a transaction iterate over a map at the latest know committed value on a node.Note that using
get_globally_committed()
in the context of a write transaction is dangerous and will potentially lead to a s…