JPPF Issue Tracker
star_faded.png
Please log in to bookmark issues
bug_report_small.png
CLOSED  Bug report JPPF-614  -  Race condition in the client prevents job recovery upon disconnection
Posted Jan 04, 2020 - updated Jan 04, 2020
icon_info.png This issue has been closed with status "Closed" and resolution "RESOLVED".
Issue details
  • Type of issue
    Bug report
  • Status
     
    Closed
  • Assigned to
     lolo4j
  • Progress
       
  • Type of bug
    Not triaged
  • Likelihood
    Not triaged
  • Effect
    Not triaged
  • Posted by
     lolo4j
  • Owned by
    Not owned by anyone
  • Category
    Client
  • Resolution
    RESOLVED
  • Priority
    Normal
  • Reproducability
    Always
  • Severity
    Normal
  • Targetted for
    icon_milestones.png JPPF 6.1.5
Issue description
Sometimes a job that is executing is not recovered when the client gets disconnected from the driver.
Steps to reproduce this issue
Use the following unit test in TestJPPFClient.java:
@Test(timeout=10000)
public void testClientClose() throws Exception {
  final TypedProperties config = new TypedProperties(JPPFConfiguration.getProperties())
    .set(LOAD_BALANCING_ALGORITHM, "manual")
    .set(LOAD_BALANCING_PROFILE, "test")
    .setInt(LOAD_BALANCING_PROFILE.getName() + ".test.size", 1);
  try (final MyClient client = new MyClient(config))  {
    final int nbJobs = 5;
    final int nbTasks = 3;
    for (int i = 1; i<=nbJobs; i++) {
      final JPPFJob job = BaseTestHelper.createJob(ReflectionUtils.getCurrentClassAndMethod() + "-" + i, false, nbTasks, LifeCycleTask.class, 0L);
      print(false, false, "----- iteration #%03d -----", i);
      int count = 0;
      for (final Task<?> task: job.getJobTasks()) task.setId("" + count++);
      final AwaitJobListener listener = AwaitJobListener.of(job, JobEvent.Type.JOB_RETURN);
      print(false, false, "submitting job");
      client.submitAsync(job);
      print(false, false, "awaiting first result");
      listener.await();
      print(false, false, "resetting client");
      final JPPFConnectionPool pool = client.awaitWorkingConnectionPool();
      pool.close();
      print(false, false, "client queue: %s", client.getQueuedJobs());
      ThreadUtils.startDaemonThread(() -> client.initPools(config), "InitPools");
      print(false, false, "awaiting job results");
      final List<Task<?>> results = job.awaitResults();
      print(false, false, "got job results");
      assertNotNull(results);
      assertEquals(nbTasks, results.size());
      final String msg = BaseTestHelper.EXECUTION_SUCCESSFUL_MESSAGE;
      for (final Task<?> task: results) {
        final Throwable t = task.getThrowable();
        assertNull("task " + task.getId() + " has an exception " + t, t);
        assertEquals("result of task " + task.getId() + " should be " + msg + " but is " + task.getResult(), msg, task.getResult());
      }
    }
  }
}