From 0c6d38221ec9fbf9d7c7e0329252b10f17ab7a27 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Thu, 23 May 2019 09:36:52 +0000 Subject: xcpdb: use fine-grained locking Copying an entire Xapian DB takes a long time, so update our reindexing code to support partial reindexing, snapshot the pre-copydatabase git revisions, perform the lengthy copy, and do a partial reindex when the copy + renames are done. --- lib/PublicInbox/SearchIdx.pm | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'lib/PublicInbox/SearchIdx.pm') diff --git a/lib/PublicInbox/SearchIdx.pm b/lib/PublicInbox/SearchIdx.pm index 114420e4..0aeeb6bc 100644 --- a/lib/PublicInbox/SearchIdx.pm +++ b/lib/PublicInbox/SearchIdx.pm @@ -542,8 +542,10 @@ sub do_cat_mail { $@ ? undef : $mime; } +# called by public-inbox-index sub index_sync { my ($self, $opts) = @_; + delete $self->{lock_path} if $opts->{-skip_lock}; $self->{-inbox}->with_umask(sub { $self->_index_sync($opts) }) } @@ -692,6 +694,12 @@ sub _last_x_commit { $lx; } +sub reindex_from ($$) { + my ($reindex, $last_commit) = @_; + return $last_commit unless $reindex; + ref($reindex) eq 'HASH' ? $reindex->{from} : ''; +} + # indexes all unindexed messages (v1 only) sub _index_sync { my ($self, $opts) = @_; @@ -705,7 +713,7 @@ sub _index_sync { do { $xlog = undef; $last_commit = _last_x_commit($self, $mm); - $lx = $opts->{reindex} ? '' : $last_commit; + $lx = reindex_from($opts->{reindex}, $last_commit); $self->{over}->rollback_lazy; $self->{over}->disconnect; -- cgit v1.2.3-24-ge0c7