Changeset 353

Show
Ignore:
Timestamp:
08/16/06 01:03:00 (2 years ago)
Author:
marksmith
Message:

* let's make the replicate job wait for the monitor job to fire a cycle before

it kicks in and starts replicating.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/server-newrepl/lib/MogileFS/ProcManager.pm

    r338 r353  
    549549 
    550550    } elsif ($cmd eq ":still_alive") { 
    551  
    552551        # a no-op 
     552 
     553    } elsif ($cmd eq ":monitor_just_ran") { 
     554        send_monitor_has_run($child); 
    553555 
    554556    } elsif ($cmd =~ /^:invalidate_meta (\w+)/) { 
     
    646648} 
    647649 
     650sub send_monitor_has_run { 
     651    my $child = shift; 
     652    for my $type (qw(replicate)) { 
     653        MogileFS::ProcManager->ImmediateSendToChildrenByJob($type, ":monitor_has_run", $child); 
     654    } 
     655} 
     656 
    6486571; 
    649658 
  • branches/server-newrepl/lib/MogileFS/Worker.pm

    r338 r353  
    44            'last_bcast_state',   # "{device|host}-$devid" => [$time, {alive|dead}] 
    55            'readbuf',            # unparsed data from parent 
     6            'monitor_has_run',    # true once we've heard of the monitor job being alive 
    67            ); 
    78 
     
    1920    $self->{readbuf}          = ''; 
    2021    $self->{last_bcast_state} = {}; 
     22    $self->{monitor_has_run}  = 0; 
    2123 
    2224    IO::Handle::blocking($psock, 0); 
     
    3032sub get_dbh { 
    3133    return Mgd::get_dbh(); 
     34} 
     35 
     36sub monitor_has_run { 
     37    my $self = shift; 
     38    return $self->{monitor_has_run} ? 1 : 0; 
    3239} 
    3340 
     
    184191    } 
    185192 
     193    if ($$lineref =~ /^:monitor_has_run/) { 
     194        $self->{monitor_has_run} = 1; 
     195        return 1; 
     196    } 
     197 
    186198    # TODO: warn on unknown commands? 
    187199 
  • branches/server-newrepl/lib/MogileFS/Worker/Monitor.pm

    r342 r353  
    126126            } 
    127127        } 
     128 
     129        # announce to the parent that we've run 
     130        $self->send_to_parent(":monitor_just_ran"); 
    128131    }); 
    129132 
  • branches/server-newrepl/lib/MogileFS/Worker/Replicate.pm

    r352 r353  
    5050    every(2.0, sub { 
    5151        $self->parent_ping; 
     52 
     53        # replication doesn't go well if the monitor job hasn't actively started 
     54        # marking things as being available 
     55        unless ($self->monitor_has_run) { 
     56            error("waiting for monitor job to complete a cycle before beginning replication"); 
     57            return; 
     58        } 
    5259 
    5360        $self->validate_dbh;