Eric Wong <[email protected]> writes:

> I wrote:
>> While testing this, it looks like I introduced a bug to
>> indexlevel=basic which broke incremental indexing when I made it
>> possible to upgrade to (medium|full).  Patch coming for that in
>> a bit...
>
> Eep, I think there's deeper problems with indexlevel=basic and
> incremental updates, since it's still doing lookups against
> Xapian for deletes...
>
> This is my work-in-progress to stop full-reindexing, at least.

So I don't think your change is quite right.

If the repo has only lived with indexlevel == 'basic' then last_commit
should always match the output of xdb->get_metadata('last_commit') as
it will always been undef or ''.

In fact I don't see any code that is updating
$xdb->get_metadata('last_commit');

Am I wrong or can we just always use mm->last_commit for this logic?

Eric

> ----8<-----
> Subject: [PATCH] searchidx: support incremental indexing on indexlevel=basic
>
> ---
>  lib/PublicInbox/SearchIdx.pm | 13 +++++++++++--
>  1 file changed, 11 insertions(+), 2 deletions(-)
>
> diff --git a/lib/PublicInbox/SearchIdx.pm b/lib/PublicInbox/SearchIdx.pm
> index 54f82aa..5cac08f 100644
> --- a/lib/PublicInbox/SearchIdx.pm
> +++ b/lib/PublicInbox/SearchIdx.pm
> @@ -668,6 +668,15 @@ sub need_update ($$$) {
>       ($n eq '' || $n > 0);
>  }
>  
> +sub _last_x_commit {
> +     my ($self) = @_;
> +     if ($self->{indexlevel} =~ $xapianlevels) {
> +             $self->{xdb}->get_metadata('last_commit');
> +     } else {
> +             $self->{mm}->last_commit || '';
> +     }
> +}
> +
>  # indexes all unindexed messages (v1 only)
>  sub _index_sync {
>       my ($self, $opts) = @_;
> @@ -682,7 +691,7 @@ sub _index_sync {
>       do {
>               $xlog = undef;
>               $mkey = 'last_commit';
> -             $last_commit = $xdb->get_metadata('last_commit');
> +             $last_commit = $self->_last_x_commit;
>               $lx = $last_commit;
>               if ($reindex) {
>                       $lx = '';
> @@ -707,7 +716,7 @@ sub _index_sync {
>               $xlog = _git_log($self, $range);
>  
>               $xdb = $self->begin_txn_lazy;
> -     } while ($xdb->get_metadata('last_commit') ne $last_commit);
> +     } while ($self->_last_x_commit ne $last_commit);
>  
>       my $dbh = $mm->{dbh} if $mm;
>       my $cb = sub {
--
unsubscribe: [email protected]
archive: https://public-inbox.org/meta/

Reply via email to