Program: 5353
Project: 5353
Buggy source:
/** 
 * Creates a service listener to reactor on state changes on   {@link MapReduceRuntimeService}.
 */
private Service.Listener createRuntimeServiceListener(final ProgramId programId,final RunId runId,final Iterable<Closeable> closeables,final Arguments arguments,final Arguments userArgs){
  final String twillRunId=arguments.getOption(ProgramOptionConstants.TWILL_RUN_ID);
  return new ServiceListenerAdapter(){
    @Override public void starting(){
      long startTimeInSeconds=RunIds.getTime(runId,TimeUnit.SECONDS);
      if (startTimeInSeconds == -1) {
        startTimeInSeconds=TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis());
      }
      runtimeStore.setStart(programId,runId.getId(),startTimeInSeconds,twillRunId,userArgs.asMap(),arguments.asMap());
    }
    @Override public void terminated(    Service.State from){
      closeAllQuietly(closeables);
      ProgramRunStatus runStatus=ProgramController.State.COMPLETED.getRunStatus();
      if (from == Service.State.STOPPING) {
        runStatus=ProgramController.State.KILLED.getRunStatus();
      }
      runtimeStore.setStop(programId,runId.getId(),TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis()),runStatus);
    }
    @Override public void failed(    Service.State from,    @Nullable Throwable failure){
      closeAllQuietly(closeables);
      runtimeStore.setStop(programId,runId.getId(),TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis()),ProgramController.State.ERROR.getRunStatus(),new BasicThrowable(failure));
    }
  }
;
}

Fixed version (ground truth):
/** 
 * Creates a service listener to reactor on state changes on   {@link MapReduceRuntimeService}.
 */
private Service.Listener createRuntimeServiceListener(final ProgramId programId,final RunId runId,final Iterable<Closeable> closeables,final Arguments arguments,final Arguments userArgs){
  final String twillRunId=arguments.getOption(ProgramOptionConstants.TWILL_RUN_ID);
  return new ServiceListenerAdapter(){
    @Override public void starting(){
      long startTimeInSeconds=RunIds.getTime(runId,TimeUnit.SECONDS);
      if (startTimeInSeconds == -1) {
        startTimeInSeconds=TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis());
      }
      final long finalStartTimeInSeconds=startTimeInSeconds;
      Retries.supplyWithRetries(new Supplier<Void>(){
        @Override public Void get(){
          runtimeStore.setStart(programId,runId.getId(),finalStartTimeInSeconds,twillRunId,userArgs.asMap(),arguments.asMap());
          return null;
        }
      }
,RetryStrategies.fixDelay(Constants.Retry.RUN_RECORD_UPDATE_RETRY_DELAY_SECS,TimeUnit.SECONDS));
    }
    @Override public void terminated(    Service.State from){
      closeAllQuietly(closeables);
      ProgramRunStatus runStatus=ProgramController.State.COMPLETED.getRunStatus();
      if (from == Service.State.STOPPING) {
        runStatus=ProgramController.State.KILLED.getRunStatus();
      }
      final ProgramRunStatus finalRunStatus=runStatus;
      Retries.supplyWithRetries(new Supplier<Void>(){
        @Override public Void get(){
          runtimeStore.setStop(programId,runId.getId(),TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis()),finalRunStatus);
          return null;
        }
      }
,RetryStrategies.fixDelay(Constants.Retry.RUN_RECORD_UPDATE_RETRY_DELAY_SECS,TimeUnit.SECONDS));
    }
    @Override public void failed(    Service.State from,    @Nullable final Throwable failure){
      closeAllQuietly(closeables);
      Retries.supplyWithRetries(new Supplier<Void>(){
        @Override public Void get(){
          runtimeStore.setStop(programId,runId.getId(),TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis()),ProgramController.State.ERROR.getRunStatus(),new BasicThrowable(failure));
          return null;
        }
      }
,RetryStrategies.fixDelay(Constants.Retry.RUN_RECORD_UPDATE_RETRY_DELAY_SECS,TimeUnit.SECONDS));
    }
  }
;
}