From: Eric Wong <e@80x24.org>
To: Kyle Meyer <kyle@kyleam.com>
Cc: meta@public-inbox.org
Subject: [WIP] over: ensure old, merged {tid} is really gone.
Date: Fri, 4 Dec 2020 02:12:34 +0000 [thread overview]
Message-ID: <20201204021234.GA24535@dcvr> (raw)
In-Reply-To: <20201203201945.GA15810@dcvr>
Eric Wong <e@80x24.org> 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 <meta@public-inbox.org>
+# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
+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;
next prev parent reply other threads:[~2020-12-04 2:12 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-03 4:59 missing messages in thread overview Kyle Meyer
2020-12-03 20:19 ` Eric Wong
2020-12-04 2:12 ` Eric Wong [this message]
2020-12-04 3:35 ` [WIP] over: ensure old, merged {tid} is really gone Kyle Meyer
2020-12-04 12:09 ` [PATCH] " Eric Wong
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=20201204021234.GA24535@dcvr \
--to=e@80x24.org \
--cc=kyle@kyleam.com \
--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).