mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

abobrov
19.48.2009 7e83f81a531a47f29c7bf828c56a38dcbf96f286
- attempt to fix possible race condition that might occur when scheduled task changes its state to done but hasnt transitioned to the completed tasks list yet.
2 files modified
17 ■■■■■ changed files
opends/src/server/org/opends/server/backends/task/TaskScheduler.java 5 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/backends/task/TaskThread.java 12 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/backends/task/TaskScheduler.java
@@ -620,17 +620,20 @@
   * @param  taskThread     The thread that has completed processing on its
   *                        previously-assigned task.
   * @param  completedTask  The task for which processing has been completed.
   * @param  taskState      The task state for this completed task.
   *
   * @return  <CODE>true</CODE> if the thread should continue running and
   *          wait for the next task to process, or <CODE>false</CODE> if it
   *          should exit immediately.
   */
  public boolean threadDone(TaskThread taskThread, Task completedTask)
  public boolean threadDone(TaskThread taskThread, Task completedTask,
    TaskState taskState)
  {
    schedulerLock.lock();
    try
    {
      completedTask.setTaskState(taskState);
      addCompletedTask(completedTask);
      String taskID = completedTask.getTaskID();
opends/src/server/org/opends/server/backends/task/TaskThread.java
@@ -193,9 +193,10 @@
        continue;
      }
      TaskState taskState = getAssociatedTask().getTaskState();
      try
      {
        if (!TaskState.isDone(getAssociatedTask().getTaskState()))
        if (!TaskState.isDone(taskState))
        {
          Task task = getAssociatedTask();
@@ -203,8 +204,7 @@
            task.getDisplayName(), task.getTaskID());
          logError(message);
          TaskState returnState = task.execute();
          task.setTaskState(returnState);
          taskState = task.execute();
          message = NOTE_TASK_FINISHED.get(
            task.getDisplayName(), task.getTaskID());
@@ -229,7 +229,7 @@
      Task completedTask = getAssociatedTask();
      setAssociatedTask(null);
      if (! taskScheduler.threadDone(this, completedTask))
      if (! taskScheduler.threadDone(this, completedTask, taskState))
      {
        exitRequested = true;
        break;
@@ -239,8 +239,8 @@
    if (getAssociatedTask() != null)
    {
      Task task = getAssociatedTask();
      task.setTaskState(TaskState.STOPPED_BY_SHUTDOWN);
      taskScheduler.threadDone(this, task);
      TaskState taskState = TaskState.STOPPED_BY_SHUTDOWN;
      taskScheduler.threadDone(this, task, taskState);
    }
  }