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

Enhance ledger to support per-channel based data deletion



    • Story
    • Status: Closed
    • Medium
    • Resolution: Done
    • None
    • v2.x
    • fabric-ledger


      We need to clean up ledger data in multiple scenarios, such as peer bootstrap crash and reset/rollback. In the past, because cross-channel data are stored in the same level db, we have chosen to drop the entire databases for simplicity. With the checkpointing support, we cannot drop the entire databases any more because the bootstrapping snapshot may not be available to rebuild the channel data. This story adds the support to delete per-channel data from the ledger instead of dropping the entire databases.


      State CouchDB has its own challenge. Individual couch databases are created to store state data at a per-chaincode/collection basis. Because CouchDB has length limitation for db names, channel name may be truncated if the combined length of channel+namespace+collection is over the limit (see https://github.com/hyperledger/fabric/blob/master/core/ledger/kvledger/txmgmt/statedb/statecouchdb/couchdbutil.go#L204). As a result, we cannot deterministically calculate the channel name if the channel name has been truncated in a couch database name. To know what couchdbs belong to a channel, we have to query the statedb to find out the deployed chaincodes and collections so that we can reconstruct the couch database names. However, if something goes wrong during channel bootstrapping, we may have partially loaded lscc, _lifecycle, and state tables and cannot query statedb to get the chaincode info. Therefore, we will add a mapping of channel names to known couchdb names for the channel, so that we know what databases to delete after crash.


      In summary, this story enhances the ledger component to allow per-channel based data deletion. This enhancement will be leveraged by bootstrap failure recovery, peer restart flow, reset/rollback, and channel unjoining.


        Issue Links



              wenjian Wenjian Qiao
              wenjian Wenjian Qiao
              0 Vote for this issue
              1 Start watching this issue