Reputation: 33
I tried to see the problem MVCC with hyperledger fabric but the problem that when I invoke transaction that modifies and reads the same variable with the same key it works.
What are the changes to make to highlight MVCC?
Upvotes: 0
Views: 102
Reputation: 5
According to https://arxiv.org/abs/2103.04681 and https://ieeexplore.ieee.org/stamp/stamp.jsp?arnumber=10418209 Peers receive blocks of transactions from orderes and do MVCC checks (validation). The MVCC checks that versions only in read sets are the same as they were during transaction simulation (execution). The peers don't check write sets! So if you do only writes for some key, they always are valid.
Transaction1: writes key1 = 1
Transaction2: writes key1 = 2
Transaction3: writes key1 = 3.
As a result the key1 is 3. And you'll get lost update (you override values 1 and 2). And fabric doesn't think it to be a validation error.
Solution: Add reads of keys:
Transaction1: reads key1 = 0 and writes key1 = 1
Transaction2: reads key1 = 0 and writes key1 = 2
Transaction3: reads key1 = 0 and writes key1 = 3.
In this case only Transaction1 is valid. After Transaction1 key1 value is 1 and key1 version is updated (incremented by 1), so Transaction2 and Transaction3 will fail (will be marked as invalid in a block), because key1 in read set is 0 (and it's version number is not the same as it was when transaction had been simulated at the peer).
Upvotes: 0
Reputation: 41222
What are the changes to make to highlight MVCC?
MVCC stands for Multi Value Concurrency Control, this is well know approach to enable optimistic update mechanism which allow to prevent concurrent modifications of the same key. In Fabric context concurrent modification would be transactions which grouped into same block and modifies same key. Therefore in order to experience MVCC failure it's not enough to modify same key several times, you also need to make sure all those transactions will be batched to the same block.
The easiest way to achieve it is to throw as much as possible tx updates to increase probability of transactions to be places into same block.
Upvotes: 0