From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: 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.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 3D29C1FB0A; Fri, 4 Dec 2020 02:12:34 +0000 (UTC) Date: Fri, 4 Dec 2020 02:12:34 +0000 From: Eric Wong To: Kyle Meyer Cc: meta@public-inbox.org Subject: [WIP] over: ensure old, merged {tid} is really gone. Message-ID: <20201204021234.GA24535@dcvr> References: <87360nlc44.fsf@kyleam.com> <20201203201945.GA15810@dcvr> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201203201945.GA15810@dcvr> List-Id: Eric Wong wrote: > It seems like the presence of two ghosts in the histories fails > to get merged together; so it's order-dependency bug in > OverIdx.pm rethread seems to be exacerbating the condition (less > sure about rethread, though). Yes, the fix is quite small (I think the below test case can be made smaller). --rethread seems to be a separate bug, will fix when more awake. -----------------8<-------------- Subject: [PATCH] over: ensure old, merged {tid} is really gone. We must use the result of link_refs() since it can trigger merge_threads() and invalidate $old_tid. In case merge_threads() isn't triggered, link_refs() will return $old_tid anyways. --- MANIFEST | 1 + lib/PublicInbox/OverIdx.pm | 2 +- t/thread-index-gap.t | 94 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 96 insertions(+), 1 deletion(-) create mode 100644 t/thread-index-gap.t diff --git a/MANIFEST b/MANIFEST index 544ec5f9..946e4b8a 100644 --- a/MANIFEST +++ b/MANIFEST @@ -366,6 +366,7 @@ t/solver_git.t t/spamcheck_spamc.t t/spawn.t t/thread-cycle.t +t/thread-index-gap.t t/time.t t/uri_imap.t t/utf8.eml diff --git a/lib/PublicInbox/OverIdx.pm b/lib/PublicInbox/OverIdx.pm index 07cca4e5..ac53518c 100644 --- a/lib/PublicInbox/OverIdx.pm +++ b/lib/PublicInbox/OverIdx.pm @@ -298,7 +298,7 @@ sub _add_over { } } elsif ($n < 0) { # ghost $$old_tid //= $cur_valid ? $cur_tid : next_tid($self); - link_refs($self, $refs, $$old_tid); + $$old_tid = link_refs($self, $refs, $$old_tid); delete_by_num($self, $n); $$v++; } diff --git a/t/thread-index-gap.t b/t/thread-index-gap.t new file mode 100644 index 00000000..1772ce22 --- /dev/null +++ b/t/thread-index-gap.t @@ -0,0 +1,94 @@ +#!perl -w +# Copyright (C) 2020 all contributors +# License: AGPL-3.0+ +use strict; +use v5.10.1; +use Test::More; +use PublicInbox::TestCommon; +use PublicInbox::Eml; +use PublicInbox::InboxWritable; +use PublicInbox::Config; +require_mods(qw(DBD::SQLite)); +require_git(2.6); +my ($home, $for_destroy) = tmpdir(); +local $ENV{HOME} = $home; +ok(run_script([qw(-init -V2 index-gap), "$home/index-gap", + qw(http://example.com/v2test index-gap@example.com)]), 'init'); +my $pi_cfg = PublicInbox::Config->new; +my $ibx = $pi_cfg->lookup_name('index-gap'); +PublicInbox::InboxWritable->new($ibx); + +chomp(my @msgs = reverse(split(/\n\n/, <<'EOF'))); +Subject: [bug#45000] [PATCH 2/9] +Message-Id: <20201202045540.31248-2-j@example.com> +In-Reply-To: <20201202045540.31248-1-j@example.com> +References: <20201202045540.31248-1-j@example.com> + +Subject: [bug#45000] [PATCH 9/9] +Message-Id: <20201202045540.31248-9-j@example.com> +In-Reply-To: <20201202045540.31248-1-j@example.com> +References: <20201202045540.31248-1-j@example.com> + +Subject: [bug#45000] [PATCH 7/9] +Message-Id: <20201202045540.31248-7-j@example.com> +In-Reply-To: <20201202045540.31248-1-j@example.com> +References: <20201202045540.31248-1-j@example.com> + +Subject: [bug#45000] [PATCH 1/9] +References: <20201202045335.31096-1-j@example.com> +In-Reply-To: <20201202045335.31096-1-j@example.com> +Message-Id: <20201202045540.31248-1-j@example.com> + +Subject: [bug#45000] [PATCH 0/9] +Message-Id: <20201202045335.31096-1-j@example.com> + +Subject: [bug#45000] [PATCH 0/9] +In-Reply-To: <20201202045335.31096-1-j@example.com> +References: <20201202045335.31096-1-j@example.com> +Message-ID: <86sg8o1mou.fsf@example.com> + +Subject: [bug#45000] [PATCH 8/9] +Message-Id: <20201202045540.31248-8-j@example.com> +In-Reply-To: <20201202045540.31248-1-j@example.com> +References: <20201202045540.31248-1-j@example.com> + +Subject: [bug#45000] [PATCH 6/9] +Message-Id: <20201202045540.31248-6-j@example.com> +In-Reply-To: <20201202045540.31248-1-j@example.com> +References: <20201202045540.31248-1-j@example.com> + +Subject: [bug#45000] [PATCH 5/9] +Message-Id: <20201202045540.31248-5-j@example.com> +In-Reply-To: <20201202045540.31248-1-j@example.com> +References: <20201202045540.31248-1-j@example.com> + +Subject: [bug#45000] [PATCH 4/9] +Message-Id: <20201202045540.31248-4-j@example.com> +In-Reply-To: <20201202045540.31248-1-j@example.com> +References: <20201202045540.31248-1-j@example.com> + +Subject: [bug#45000] [PATCH 3/9] +Message-Id: <20201202045540.31248-3-j@example.com> +In-Reply-To: <20201202045540.31248-1-j@example.com> +References: <20201202045540.31248-1-j@example.com> +EOF + +my $im = $ibx->importer(0); +for my $msg (@msgs) { + $im->add(PublicInbox::Eml->new("$msg\nFrom: x\@example.com\n\n")); +} +$im->done; + +my @tid = $ibx->over->dbh->selectall_array('SELECT DISTINCT(tid) FROM over'); +is(scalar(@tid), 1, 'only one thread'); + +if (0 && 'FIXME') { + $ibx->over->dbh_close; + ok(run_script([qw(-index --reindex --rethread -v), $ibx->{inboxdir}]), + 'rethread'); + @tid = $ibx->over->dbh->selectall_array( + 'SELECT DISTINCT(tid) FROM over'); + is(scalar(@tid), 1, 'only one thread after rethread'); +} + +done_testing;