From feb4a75affbe5f940116dc4f6bcc5ddb52a110b4 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 7 May 2017 10:49:00 +0000 Subject: searchidx: fix ghost root vivification Due to the asynchronous nature of SMTP, it is possible for the root message of a thread (with no References/In-Reply-To) to arrive last in a series. We must preserve the thread_id of the ghost message in this case, as we do when vivifiying non-root ghosts. Otherwise, this causes threads to be broken when the root arrives last. --- lib/PublicInbox/Search.pm | 3 ++- lib/PublicInbox/SearchIdx.pm | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/PublicInbox/Search.pm b/lib/PublicInbox/Search.pm index bc2b6985..82a6e541 100644 --- a/lib/PublicInbox/Search.pm +++ b/lib/PublicInbox/Search.pm @@ -41,7 +41,8 @@ use constant { # 12 - change YYYYMMDD value column to numeric # 13 - fix threading for empty References/In-Reply-To # (commit 83425ef12e4b65cdcecd11ddcb38175d4a91d5a0) - SCHEMA_VERSION => 13, + # 14 - fix ghost root vivification + SCHEMA_VERSION => 14, # 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 8a529c66..e4e3c81b 100644 --- a/lib/PublicInbox/SearchIdx.pm +++ b/lib/PublicInbox/SearchIdx.pm @@ -330,7 +330,7 @@ sub link_message { merge_threads($self, $tid, $ptid); } } else { - $tid = $self->next_thread_id; + $tid = defined $old_tid ? $old_tid : $self->next_thread_id; } $doc->add_term(xpfx('thread') . $tid); } -- cgit v1.2.3-24-ge0c7