Commit Phase Re-Validation - Phantom Reads


Tomás Peixinho
 

Good afternoon,

I'm developing an application using Hyperledger Fabric that requires me to, in order to do an insertion on the blockchain, check a lot of the stored keys, so that it can know which one it needs to update. For this, I'm using the getStateByPartialCompositeKey function from the Java SDK, and then I'm iterating over the results to find the specific key that needs to be updated (because due to the rules of the application, I can't insert the key as a new transaction, some keys are supposed to be sub-keys of others). 

The problem with this is that, since there are multiple transactions being sent all the time, the world state is always being updated (between endorsement time and commit validation time), which means that for every transaction that is accepted, there are a ton that are invalidated due to phantom reads.

My question is if there is any way around this. Is there any way to disable the commit phase validation? And even if there were, what would happen if two transactions altered the same key at the same time? What would actually be stored in the world state of the blockchain? And is it possible to achieve this using an external CouchDB database? Or would I have the same problem when I performed the queries to find the keys? If possible, would it be ok to disable commit time validation, if I handled the "double-spend" on the client side? And if ultimately there is no way around this, what is the purpose of these ranged type queries? Is it just for printing/showing what is stored? Seems counter-intuitive.

This is very problematic for my project (and for the scope of a blockchain in general), because what happens is it almost only inserts transactions sequentially. There is no point in handling transactions concurrently (I'm doing it using threads), because most of them will fail due to phantom reads.

I'm really stumped with this, any ideas would be helpful!

Thank you very much

Tomás 

Join fabric@lists.hyperledger.org to automatically receive all group messages.