3550: Fix race conditions: avoid setting running/success/finished_at
authorTom Clegg <tom@curoverse.com>
Wed, 17 Sep 2014 15:13:14 +0000 (11:13 -0400)
committerTom Clegg <tom@curoverse.com>
Wed, 17 Sep 2014 15:13:14 +0000 (11:13 -0400)
attributes until output and log have been saved.

sdk/cli/bin/crunch-job

index 83931f2c6546e33f4821bb40d19b373cd0f20e34..613be70ef168aad21d27029b2740d0e9fbc29994 100755 (executable)
@@ -848,12 +848,6 @@ release_allocation();
 freeze();
 my $collated_output = &collate_output();
 
-if ($job_has_uuid) {
-  $Job->update_attributes('running' => 0,
-                          'success' => $collated_output && $main::success,
-                          'finished_at' => scalar gmtime)
-}
-
 if (!$collated_output) {
   Log(undef, "output undef");
 }
@@ -880,6 +874,13 @@ else {
 Log (undef, "finish");
 
 save_meta();
+
+if ($job_has_uuid) {
+  $Job->update_attributes('running' => 0,
+                          'success' => $collated_output && $main::success,
+                          'finished_at' => scalar gmtime)
+}
+
 exit ($Job->{'success'} ? 1 : 0);