Fix race between hydra-eval-jobs and hydra-update-gc-roots

[?]
Jul 14, 2014, 11:18 AM
3D3F5I744YILPYZYZQHGADFNYIM7RESDLSCDULH5WVIIPTYD5GYQC

Dependencies

  • [2] PMNWRTGJ Add multiple output support
  • [3] ACFFJUAN hydra-update-gc-roots: Keep more evals
  • [4] WZ3AEJ67 * hydra_update_gc_roots.pl registers build outputs that should be kept
  • [5] FP72ASZX No wonder our disk was filling up
  • [6] IN272KZW * Automatically keep all builds in the latest successful release in
  • [7] KJQWSRCC Speed up hydra-update-gc-roots
  • [8] SZPBGW2N Fix a race condition in hydra-update-gc-roots
  • [9] 4X6NS66Q * Keep the most recent builds for each job.

Change contents

  • edit in src/script/hydra-update-gc-roots at line 5
    [3.544]
    [3.544]
    use File::stat;
  • replacement in src/script/hydra-update-gc-roots at line 52
    [3.1148][3.0:149]()
    # Read the current GC roots. We need to do that here so that we don't
    # delete roots that were added while we were determining the desired
    # roots.
    [3.1148]
    [3.149]
    # Read the current GC roots.
  • edit in src/script/hydra-update-gc-roots at line 124
    [3.2766]
    [3.2064]
    my $now = time();
  • replacement in src/script/hydra-update-gc-roots at line 130
    [3.2221][3.2221:2267](),[3.2267][2.19656:19681](),[2.19681][3.0:78](),[3.2864][3.0:78]()
    print STDERR "removing root $path\n";
    $rootsDeleted++;
    unlink "$gcRootsDir/$link" or warn "cannot remove $gcRootsDir/$link";
    [3.2221]
    [3.2942]
    # Don't delete roots that are less than a day old, to prevent
    # a race where hydra-eval-jobs has added a root but
    # hydra-evaluator hasn't added them to the database yet.
    if (lstat($path)->ctime < $now - 24 * 60 * 60) {
    print STDERR "removing root $path\n";
    $rootsDeleted++;
    unlink "$gcRootsDir/$link" or warn "cannot remove $gcRootsDir/$link";
    } else {
    print STDERR "NOT removing recent root $path\n";
    $rootsKept++;
    }