Changeset 4098


Ignore:
Timestamp:
Jan 23, 2008, 3:13:38 PM (15 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #887: Internal job queue may start the same job more than once if running BASE on multiple Tomcat instances

As it turned out, the checks were already implemented by the job agent code and just needed to be copied into the internal job queue code.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/core/net/sf/basedb/core/InternalJobQueue.java

    r4078 r4098  
    433433        if (job.getStatus() != Job.Status.WAITING) return;
    434434       
     435        // Change the status to Job.Status.PREPARED
     436        job.setPrepared(Application.getHostName());
     437        try
     438        {
     439          dc.commit();
     440        }
     441        catch (ItemModifiedException ex)
     442        {
     443          // Another thread or process has started the job already, return
     444          // without starting the job
     445          return;
     446        }
     447        finally
     448        {
     449          dc.close();
     450        }
     451        // Now we know that noby else is trying to execute the job
     452        // Reload the job again in a new DbControl
     453        dc = impersonated.newDbControl();
     454        job = Job.getById(dc, jobId);
     455       
    435456        // Set the active project
    436457        int projectId = job.getActiveProjectId();
Note: See TracChangeset for help on using the changeset viewer.