user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 2/2] searchidx: merge old thread id from ghosts
Date: Tue, 21 Jun 2016 04:28:59 +0000	[thread overview]
Message-ID: <20160621042859.16146-3-e@80x24.org> (raw)
In-Reply-To: <20160621042859.16146-1-e@80x24.org>

We failed to discard old thread IDs when vivifying ghosts
due to out-of-order message arrival.  This rectifies the
failure and will trigger a re-index.
---
 lib/PublicInbox/Search.pm    | 3 ++-
 lib/PublicInbox/SearchIdx.pm | 5 +++--
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/lib/PublicInbox/Search.pm b/lib/PublicInbox/Search.pm
index 8c0bab1..bf50365 100644
--- a/lib/PublicInbox/Search.pm
+++ b/lib/PublicInbox/Search.pm
@@ -36,7 +36,8 @@ use constant {
 	# 8 - remove redundant/unneeded document data
 	# 9 - disable Message-ID compression (SHA-1)
 	# 10 - optimize doc for NNTP overviews
-	SCHEMA_VERSION => 10,
+	# 11 - merge threads when vivifying ghosts
+	SCHEMA_VERSION => 11,
 
 	# n.b. FLAG_PURE_NOT is expensive not suitable for a public website
 	# as it could become a denial-of-service vector
diff --git a/lib/PublicInbox/SearchIdx.pm b/lib/PublicInbox/SearchIdx.pm
index 3134687..58eccc1 100644
--- a/lib/PublicInbox/SearchIdx.pm
+++ b/lib/PublicInbox/SearchIdx.pm
@@ -150,7 +150,7 @@ sub add_message {
 
 		if ($was_ghost) {
 			$doc_id = $smsg->doc_id;
-			$self->link_message($smsg);
+			$self->link_message($smsg, $smsg->thread_id);
 			$doc->set_data($smsg->to_doc_data);
 			$db->replace_document($doc_id, $doc);
 		} else {
@@ -211,7 +211,7 @@ sub next_thread_id {
 }
 
 sub link_message {
-	my ($self, $smsg) = @_;
+	my ($self, $smsg, $old_tid) = @_;
 	my $doc = $smsg->{doc};
 	my $mid = $smsg->mid;
 	my $mime = $smsg->mime;
@@ -247,6 +247,7 @@ sub link_message {
 		# but we can never trust clients to do the right thing
 		my $ref = shift @refs;
 		$tid = $self->_resolve_mid_to_tid($ref);
+		$self->merge_threads($tid, $old_tid) if defined $old_tid;
 
 		# the rest of the refs should point to this tid:
 		foreach $ref (@refs) {

  parent reply	other threads:[~2016-06-21  4:29 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-21  4:28 [PATCH 0/2] searchidx: fix ghost vivification Eric Wong
2016-06-21  4:28 ` [PATCH 1/2] searchidx: simplify ghost creation Eric Wong
2016-06-21  4:28 ` Eric Wong [this message]
2016-06-21 21:26   ` [PATCH 2/2] searchidx: merge old thread id from ghosts 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=20160621042859.16146-3-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).