Skip to content

Commit

Permalink
[FAB-8844] correct handling of launch errors
Browse files Browse the repository at this point in the history
An error during launch is incorrectly handled by partial deregistration.
This error maybe benign and ignored by system, thus causing the
deregistration to leave it in an inconsitent state where it believes
the chaincode is not registered (and running) when it actually is.
This causes subsequent invoke to attempt to restart.

The fix is to have errors handled at the right decision point with existing
error mechanism naturally handling them..

Change-Id: I9c655a5355991b2426b88986aa7da1f7145ba15e
Signed-off-by: Srinivasan Muralidharan <srinivasan.muralidharan99@gmail.com>
  • Loading branch information
muralisrini committed Mar 14, 2018
1 parent bf53291 commit d16ce12
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions core/chaincode/chaincode_support.go
Original file line number Diff line number Diff line change
Expand Up @@ -542,10 +542,12 @@ func (chaincodeSupport *ChaincodeSupport) launchAndWaitForRegister(ctxt context.
if err == nil {
err = resp.(container.VMCResp).Err
}

//if the launch was successful and leads to proper registration,
//this error could be ignored in the select below. On the other
//hand the error might be triggered for select in which case
//the launch will be cleaned up
err = errors.WithMessage(err, "error starting container")
chaincodeSupport.runningChaincodes.Lock()
delete(chaincodeSupport.runningChaincodes.chaincodeMap, canName)
chaincodeSupport.runningChaincodes.Unlock()
}
}()

Expand Down

0 comments on commit d16ce12

Please sign in to comment.