code: private void checkCancelRequestedFlag() {
  
  		if (this.cancelRequested.compareAndSet(true, false)) {
  			final TaskCancelResult tsr = cancelTask();
  			if (tsr.getReturnCode() != AbstractTaskResult.ReturnCode.SUCCESS
  				&& tsr.getReturnCode() != AbstractTaskResult.ReturnCode.TASK_NOT_FOUND) {
  				LOG.error("Unable to cancel vertex " + this + ": " + tsr.getReturnCode().toString()
  					+ ((tsr.getDescription() != null) ? (" (" + tsr.getDescription() + ")") : ""));
  			}
  		}
  	}
docs: Checks if another thread requested the vertex to cancel while it was in state STARTING. If so, the method clears
  the respective flag and repeats the cancel request.