From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.0 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 958311F42D for ; Thu, 5 Apr 2018 21:45:28 +0000 (UTC) From: "Eric Wong (Contractor, The Linux Foundation)" To: meta@public-inbox.org Subject: [PATCH 1/4] v2writable: allow tracking parallel versions Date: Thu, 5 Apr 2018 21:45:25 +0000 Message-Id: <20180405214528.19403-2-e@80x24.org> In-Reply-To: <20180405214528.19403-1-e@80x24.org> References: <20180405214528.19403-1-e@80x24.org> List-Id: For upgrades, this will let users keep an old version running while performing "public-inbox-index" on the newest version. --- lib/PublicInbox/Msgmap.pm | 9 ++++++--- lib/PublicInbox/V2Writable.pm | 17 +++++++++++------ 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/lib/PublicInbox/Msgmap.pm b/lib/PublicInbox/Msgmap.pm index 5c37e16..f5f8843 100644 --- a/lib/PublicInbox/Msgmap.pm +++ b/lib/PublicInbox/Msgmap.pm @@ -92,9 +92,12 @@ sub last_commit { $self->meta_accessor('last_commit', $commit); } -sub last_commit_n { - my ($self, $i, $commit) = @_; - $self->meta_accessor('last_commit'.$i, $commit); +# v2 uses this to keep track of how up-to-date Xapian is +# old versions may be automatically GC'ed away in the future, +# but it's a trivial amount of storage. +sub last_commit_xap { + my ($self, $version, $i, $commit) = @_; + $self->meta_accessor("last_xap$version-$i", $commit); } sub created_at { diff --git a/lib/PublicInbox/V2Writable.pm b/lib/PublicInbox/V2Writable.pm index 8323846..ea116f1 100644 --- a/lib/PublicInbox/V2Writable.pm +++ b/lib/PublicInbox/V2Writable.pm @@ -71,7 +71,7 @@ sub new { lock_path => "$dir/inbox.lock", # limit each repo to 1GB or so rotate_bytes => int((1024 * 1024 * 1024) / $PACKING_FACTOR), - last_commit => [], + last_commit => [], # git repo -> commit }; $self->{partitions} = count_partitions($self) || nproc(); bless $self, $class; @@ -339,15 +339,20 @@ sub purge { $purges; } +sub last_commit_part ($$;$) { + my ($self, $i, $cmt) = @_; + my $v = PublicInbox::Search::SCHEMA_VERSION(); + $self->{mm}->last_commit_xap($v, $i, $cmt); +} + sub set_last_commits ($) { my ($self) = @_; defined(my $max_git = $self->{max_git}) or return; - my $mm = $self->{mm}; my $last_commit = $self->{last_commit}; foreach my $i (0..$max_git) { defined(my $cmt = $last_commit->[$i]) or next; $last_commit->[$i] = undef; - $mm->last_commit_n($i, $cmt); + last_commit_part($self, $i, $cmt); } } @@ -673,13 +678,13 @@ sub reindex_oid { # only update last_commit for $i on reindex iff newer than current sub update_last_commit { my ($self, $git, $i, $cmt) = @_; - my $last = $self->{mm}->last_commit_n($i); + my $last = last_commit_part($self, $i); if (defined $last && is_ancestor($git, $last, $cmt)) { my @cmd = (qw(rev-list --count), "$last..$cmt"); chomp(my $n = $git->qx(@cmd)); return if $n ne '' && $n == 0; } - $self->{mm}->last_commit_n($i, $cmt); + last_commit_part($self, $i, $cmt); } sub git_dir_n ($$) { "$_[0]->{-inbox}->{mainrepo}/git/$_[1].git" } @@ -688,7 +693,7 @@ sub last_commits { my ($self, $max_git) = @_; my $heads = []; for (my $i = $max_git; $i >= 0; $i--) { - $heads->[$i] = $self->{mm}->last_commit_n($i); + $heads->[$i] = last_commit_part($self, $i); } $heads; } -- EW