salman faris
salman faris

Reputation: 125

Hyperledger transaction become failed when submit transaction in for loop

I successfully deployed my network file(.bna). Then I started a REST API using command composer-rest-server. I submit a single transaction using my front end Laravel application. When I try using for loop for submitting multiple transactions, I get an error in some time that MVCC_READ_CONFLICT. I decrease my network's bachtimeout. But the error continues. Please answer anyone if you have any idea about this issue.

Fabric vertion: 1.1.0 Composer : .19.16 Node :8.12 OS: Ubuntu 16.04

Upvotes: 0

Views: 680

Answers (2)

user3664964
user3664964

Reputation: 11

lower the latency of the block creation so that blocks will be created more frequently and thus peers would be updated faster, for example, max_message_count=1 .but that may lead to some performance issue

Upvotes: 1

Artem Barger
Artem Barger

Reputation: 41222

Well, MVCC_READ_CONFLICT means you are doing concurrent modification for some key in two different transactions, hence after transaction being ordered into block, whatever transaction gets in first committed while second one or subsequent transaction which works on same key marked invalid with MVCC_READ_CONFLICT.

To understand better the reason behind this status it's probably worth noting the transaction flow in fabric:

  1. Client submit transaction proposal for endorsement sending it to endorsing peers
  2. Endorsing peers executes simulation of chaincode where execution results are captured into Read-Write Set
  3. Client collects endorsements and composes transaction, submitting it for ordering
  4. Ordering service batches transactions into block employing total order of transactions
  5. Block distributed between peers
  6. Peer conducts validation to attest conformance with endorsement policy for each transaction
  7. After that there is multi value concurrency control (MVCC), which checks for concurrent modifications, in fact validating keys version of RWSet and if concurrent modification detected tx invalidated with status MVCC_READ_CONFLICT

You can find more details in documentation "Transaction Flow".

Upvotes: 2

Related Questions