user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
From: "Eric Wong (Contractor, The Linux Foundation)" <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 1/4] v2writable: allow tracking parallel versions
Date: Thu,  5 Apr 2018 21:45:25 +0000	[thread overview]
Message-ID: <20180405214528.19403-2-e@80x24.org> (raw)
In-Reply-To: <20180405214528.19403-1-e@80x24.org>

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


  reply	other threads:[~2018-04-05 21:45 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-05 21:45 [PATCH 0/4] a few more v2 updates Eric Wong (Contractor, The Linux Foundation)
2018-04-05 21:45 ` Eric Wong (Contractor, The Linux Foundation) [this message]
2018-04-05 21:45 ` [PATCH 2/4] v2writable: refer to git each repository as "epoch" Eric Wong (Contractor, The Linux Foundation)
2018-04-05 21:45 ` [PATCH 3/4] over: use only supported and safe SQLite APIs Eric Wong (Contractor, The Linux Foundation)
2018-04-05 21:45 ` [PATCH 4/4] search: index and allow searching by date-time Eric Wong (Contractor, The Linux Foundation)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://public-inbox.org/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180405214528.19403-2-e@80x24.org \
    --to=e@80x24.org \
    --cc=meta@public-inbox.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).