Uploaded image for project: 'Fabric'
  1. Fabric
  2. FAB-10558

Blind writes to CouchDB fails on bulk update API

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • High
    • Resolution: Done
    • None
    • v1.2.0
    • fabric-ledger
    • None

    Description

      When testing private data as in FAB-10162, the transfer marble function shows a Warning:

      2018-06-06 05:46:01.976 EDT [couchdb] BatchUpdateDocuments -> DEBU 80c Exiting BatchUpdateDocuments() _bulk_docs response=[[{"id":"marble1","error":"conflict","reason":"Document update conflict."}]
      ]
      2018-06-06 05:46:01.976 EDT [statecouchdb] commitUpdates -> WARN 80d CouchDB batch document update encountered an problem. Retrying update for document ID:marble1

      The bulk update API _bulk_docs fails for the private key, causing a retry of individual documents, which ends up succeeding. 

      The bulk update API works for the hashed key.

      The difference is that with the hashed key, the couchdb revision is already in the cache from the MVCC check, and it gets placed correctly in the bulk docs JSON, like this:

      {
         "docs":[
            {
               "_attachments":{
                  "valueBytes":{
                     "content_type":"application/octet-stream",
                     "data":"mFJRmeLWhOm91wzwzoMaNuy+cofgYZH13EIS6g8BfLw="
                  }
               },
               "_id":"Xh+Ub+BxXeA2bQnoSAutdnKiNVFXApsN37yVhQ8EVw4=",
               "_rev":"1-d52448bfeb0fde7cc02163f804861cc6",
               "~version":"4:0"
            }
         ]
      }

      However with the private key, it is a blind write (no entry in readset), which means that the couchdb revision is not yet in the cache.  Note that the revision is missing in the bulk docs JSON:

       

      {
         "docs":[
            {
               "_id":"marble1",
               "color":"blue",
               "docType":"marble",
               "name":"marble1",
               "owner":"jerry",
               "size":35,
               "~version":"4:0"
            }
         ]
      }

      Interestingly, the missing revision did kick off a batch retrieve as expected, to retrieve the revision id:

      2018-06-06 05:46:01.971 EDT [couchdb] BatchRetrieveDocumentMetadata -> DEBU 7fb Entering BatchRetrieveDocumentMetadata()  keys=[marble1]
      2018-06-06 05:46:01.971 EDT [couchdb] handleRequest -> DEBU 7fc Entering handleRequest()  method=POST  url=http://127.0.0.1:5984/mycp_marblesp$$pcollection$marbles/_all_docs?include_docs=true

      But somehow the revision id did not make it into the eventual bulk docs update API JSON.

      I suspect the problem got introduced during the CouchDB batch processing refactor  https://gerrit.hyperledger.org/r/#/c/19093/ , but wasn't noticed initially since the individual retries would hide any problem with the bulk API.

      Attachments

        Issue Links

          Activity

            People

              manish-sethi Manish Sethi
              denyeart David Enyeart
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: