code: func (ctl *Controller) finishShard(c context.Context, shardID, processedCount int64, shardErr error) error {
  	err := shardTxn(c, shardID, func(c context.Context, sh *shard) (save bool, err error) {
  		runtime := clock.Now(c).Sub(sh.Created)
  		switch {
  		case shardErr == errJobAborted:
  			logging.Warningf(c, "The job has been aborted, aborting the shard after it has been running %s", runtime)
  			sh.State = State_ABORTED
  			sh.Error = errJobAborted.Error()
  		case shardErr != nil:
  			logging.Errorf(c, "The shard processing failed in %s with error: %s", runtime, shardErr)
  			sh.State = State_FAIL
  			sh.Error = shardErr.Error()
  		default:
  			logging.Infof(c, "The shard processing finished successfully in %s", runtime)
  			sh.State = State_SUCCESS
  		}
  		sh.ProcessedCount += processedCount
  		return true, ctl.requestJobStateUpdate(c, sh.JobID, sh.ID)
  	})
  	return errors.Annotate(err, "when marking the shard as finished").Err()
  }
docs: // finishShard marks the shard as finished (with status based on shardErr) and
  // emits a task to update the parent job's status.