Uploaded image for project: 'OptaPlanner'
  1. OptaPlanner
  2. PLANNER-2611

SolverManager Race Condition: Double Terminate when SOLVING_SCHEDULED

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Minor
    • None
    • None
    • optaplanner-core
    • None
    • NEW
    • NEW

    Description

      If `terminateEarly` is called from two separate threads when SOLVING_SCHEDULED, it is possible for two threads to be in solvingTerminated at once, which allows this sequence of events:

       

      1. Thread 1, Thread 2 are in solvingTerminated
      2. Thread 1 unregister the solver job, which allows a new solver job to be created with the same Problem Id
      3. Thread 3 creates a new SolverJob with the same Problem Id
      4. Thread 2 unregister the solver job

      Now Thread 3 have a SolverJob with a given problemId (that is either SOLVING_SCHEDULED or SOLVING), yet solverManager.getSolverStatus(problemId) == NOT_SOLVING. This allows for another SolverJob to be created with the same problemId, that can be cancelled via the SolverJob Thread 3 has.

       

      The race condition is extremely hard to trigger.

      Attachments

        Activity

          People

            cchianel Christopher Chianelli
            cchianel Christopher Chianelli
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: