From d85ebd01b8b3a290aa386f4e72dcbd73585cc09b Mon Sep 17 00:00:00 2001 From: "Andreas J. Koenig" Date: Tue, 14 Oct 2008 08:25:23 +0200 Subject: [PATCH] throw the secondaryttl stuff out because it is arbitrary; try to get the chain from merged to minmax closed -- WIP, no tests --- Todo | 8 +++++-- lib/File/Rsync/Mirror/Recent.pm | 47 ++++++++++--------------------------- lib/File/Rsync/Mirror/Recentfile.pm | 2 +- 3 files changed, 20 insertions(+), 37 deletions(-) diff --git a/Todo b/Todo index 4c52c7c..38fe17e 100644 --- a/Todo +++ b/Todo @@ -1,3 +1,7 @@ +2008-10-14 Andreas J. Koenig + + * revisit all $rfs->[$i+1] places if they now make sense still + 2008-10-11 Andreas J. Koenig * another bug is the fact that the mirror command deletes files before @@ -33,10 +37,10 @@ And we must understand what the impact is on the DONE system. Can it go unnoticed that there was a hole? And could the DONE system have decided - the hole is covered? This sould be testable with three directories where + the hole is covered? This should be testable with three directories where the middle stops working for a while. Done->merge is suspicious, we must stop it from merging non-conflatable neighbors due to broken continuity. - + * dirtymark now lives in Recentfile, needs to be used in rmirror. 2008-10-10 Andreas J. Koenig diff --git a/lib/File/Rsync/Mirror/Recent.pm b/lib/File/Rsync/Mirror/Recent.pm index bf932e2..5c4c1ce 100644 --- a/lib/File/Rsync/Mirror/Recent.pm +++ b/lib/File/Rsync/Mirror/Recent.pm @@ -22,6 +22,7 @@ use File::Basename qw(basename dirname fileparse); use File::Copy qw(cp); use File::Path qw(mkpath); use File::Rsync; +use File::Rsync::Mirror::Recentfile::FakeBigFloat qw(:all); use File::Temp; use List::Pairwise qw(mapp grepp); use List::Util qw(first max); @@ -150,19 +151,6 @@ File::Rsync object used to run the mirror. Minimum time before fetching the principal recentfile again. -=item secondary_timestamp - -Remembers when we ttl'd the secondary recentfile objects (not the -principal) for the last time. - -=item secondaryttl - -During normal, healthy operation, only the principal recentfile is -needed on slaves. But sometimes it is desireable to fetch them all, -even if we have downloaded the whole lot of ordinary files. If -secondaryttl is set, we will update the unneeded recentfiles after -this interval. - =item verbose Boolean to turn on a bit verbosity. This is in experimental stage, we @@ -457,7 +445,6 @@ parameter: _runstatusfile => "recent-rmirror-state-$t.yml", _logfilefordone => "recent-rmirror-donelog-$t.log", ttl => 5, - secondaryttl => 900, ); push @rrr, $rrr; } @@ -492,8 +479,6 @@ sub rmirror { $rfs->[$i]->done->_logfile($logfile); } } - $self->secondary_timestamp(time) unless - $self->secondary_timestamp(); LOOP: while () { my $ttleave = time + $minimum_time_per_loop; RECENTFILE: for my $i (0..$#$rfs) { @@ -506,7 +491,9 @@ sub rmirror { $self->_max_one_state(1); } if ($rf->uptodate){ - $rfs->[$i+1]->done->merge($rf->done) if $i < $#$rfs; + if ($i < $#$rfs){ + $rfs->[$i+1]->done->merge($rf->done); + } next RECENTFILE; } else { WORKUNIT: while (time < $ttleave) { @@ -537,18 +524,6 @@ sub rmirror { } } -sub _rmirror_secondaryttl { - my($self, $ttl) = @_; - if (time > $self->secondary_timestamp + $ttl) { - my @names; - for my $xrf (@{$self->recentfiles}) { - $xrf->seed; - push @names, $xrf->interval; - } - $self->secondary_timestamp(time); - } -} - sub _rmirror_mirror { my($self, $i, $options) = @_; my $rfs = $self->recentfiles; @@ -559,9 +534,6 @@ sub _rmirror_mirror { } $locopt{piecemeal} = 1; $rf->mirror (%locopt); - if ($rf->seeded) { - $rfs->[$i+1]->seed if $i < $#$rfs; - } } sub _rmirror_sleep_per_connection { @@ -580,8 +552,15 @@ sub _rmirror_cleanup { for my $k (keys %$pathdb) { delete $pathdb->{$k}; } - if (my $ttl = $self->secondaryttl) { - $self->_rmirror_secondaryttl ($ttl); + my $rfs = $self->recentfiles; + for my $i (0..$#$rfs-1) { + my $thismerged = $rfs->[$i]->merged; + my $next = $rfs->[$i+1]; + my $nextminmax = $next->minmax; + if (_bigfloatlt($nextminmax->{max},$thismerged->{epoch})){ + $next->seed; + warn sprintf "DEBUG: %s seeded\n", $next->interval; + } } } diff --git a/lib/File/Rsync/Mirror/Recentfile.pm b/lib/File/Rsync/Mirror/Recentfile.pm index c991ee6..460ad6b 100644 --- a/lib/File/Rsync/Mirror/Recentfile.pm +++ b/lib/File/Rsync/Mirror/Recentfile.pm @@ -837,7 +837,7 @@ sub _merge_something_done { $self->write_recent($recent); $other->merged({ time => Time::HiRes::time, # not used anywhere - epoch => $epoch, # used in oldest_allowed + epoch => $my_recent->[0]{epoch}, into_interval => $self->interval, # not used anywhere }); $other->write_recent($other_recent); -- 2.11.4.GIT