DIRACGrid/DIRAC — pull request #1763 by remenska (2013-12-20 13:29:06+00:00)
Title: Race condition that causes a job to remain in Staging

The set of events:
JobScheduling sets a request to the stager system, and within this request (setRequest method):
1 Stager service creates a New task for it
2 Stager service checks if all files already exist in the system. If they are all Staged, the status of the task is set to Staged *immediately*
3 Request finalization agent *very quickly* finds that the task is Staged, issues a callback to JobStateUpdateHandler service
4 JobStateUpdateHandler checks the last JobDB status for this job, finds that it's not Staging at all, ignores it (see below why)
JobScheduling only *NOW* updates the Job state = Staging.

causes a race-condition. As a result, even though all files are staged, the job will remain in staging.