v2.0.0, v2.1.0, v2.0.1
- Use HLF v2.0.0 ~
- Use CouchDB as statedb with cache
- Chaincode use struct as data (The fields are not ordered alphabetically)
- With single peer : It can occurred after calling GetState between 2 invocations of PutState on same key.
Before 2nd PutState, the keys in the query result would be alphabetically ordered.
After 2nd PutState, they would be ordered as fields in struct.
But it's not a big problem.
- Multiple peers : It can occurred one peer calling GetState between 2 invocations of PutState on same key, another peer does not.
On this situation, GetState result from 2 peers would be different.
And if there's an invocation that includes GetState, it would fail with the error 'Inconsistent Response Payload from Different peers.'
The cache of statecouchdb loads data when chaincode calls GetState, and update cache when process transaction - only the key is exist in cache.
When loading, the data is marshalled as alphabetically ordererd.( keyValToCouchDoc func )
When updating, the data is marshalled order of fields in struct.( In the writeset )
I make 2 solutions for this symptom.
Solution 1 : Unmarshall and marshall data before update cache
.Good points - Keep current architecture
.Bad points - Not so efficient
Solution 2 : Do not update cache - just remove when updated
.Good points - Very simple
No need of hold new value in committer
.Bad points - Cache miss can be occurred one more time
I've already test both solutions, and they solve the problem.
I'm ready to contribute.