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

Remove ledger resources asynchronously

    XMLWordPrintable

Details

    • Story
    • Status: Closed
    • Medium
    • Resolution: Done
    • None
    • v2.3.0
    • fabric-orderer

    Description

      In this task FAB-17964 the ledger resources are removed in a synchronous way. This may create problems when the channel's ledger is big. Here we improve upon that by removing the ledger in an asynch fashion. (see review comments here  and here ).

       

      The `r.ledgerFactory.Remove(channelID)` operation may take a long time. This operation is performed under the global registrar lock. If this takes even more then a fraction of a second, it will impact the performance of the server on all other channels. This method

      // GetChain retrieves the chain support for a chain if it exists.

      func (r *Registrar) GetChain(chainID string) *ChainSupport 

      {

      r.lock.RLock()

      defer r.lock.RUnlock()

      return r.chains[chainID]

      }

      is called by every client request, through BroadcastChannelSupport  so we can't really hold that lock for too long (for write - exclusive).

      What is propose is asynch deletion:

      • introduce a pendingRemove map (e.g. map[string]bool ) that holds channels that are being removed.
      • After stopping the channel move the channelID to that map,
      • and only then delete the ledger, but make the delete async with a different go-routine.
      • release the lock.
      • when the delete go-routine finishes, it removes the channelID from the pendingRemove
      • if the go-routine fails to remove the channel, it sets pendingRemove[channelID]=false
      • any attempt to `Join` or `Remove` should also check the pendingRemove

      Attachments

        Issue Links

          Activity

            People

              tsharris Tiffany Harris
              tock Yoav Tock
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: