unofficial mirror of meta@public-inbox.org
 help / color / mirror / Atom feed
From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH] extindex: guard against buggy unrefs
Date: Thu, 14 Oct 2021 05:49:33 +0000	[thread overview]
Message-ID: <20211014054933.5104-1-e@80x24.org> (raw)

I noticed some unref messages which shouldn't have been
happening, but they were.  Which is troubling.  So add
a guard around an unref path until we can get to the bottom
of this.
---
 lib/PublicInbox/ExtSearchIdx.pm | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/lib/PublicInbox/ExtSearchIdx.pm b/lib/PublicInbox/ExtSearchIdx.pm
index 750ced5c..363e5665 100644
--- a/lib/PublicInbox/ExtSearchIdx.pm
+++ b/lib/PublicInbox/ExtSearchIdx.pm
@@ -18,6 +18,7 @@ use strict;
 use v5.10.1;
 use parent qw(PublicInbox::ExtSearch PublicInbox::Lock);
 use Carp qw(croak carp);
+use Scalar::Util qw(blessed);
 use Sys::Hostname qw(hostname);
 use POSIX qw(strftime);
 use File::Glob qw(bsd_glob GLOB_NOSORT);
@@ -143,6 +144,14 @@ sub _unref_doc ($$$$$;$) {
 		$smsg = $docid;
 		$docid = $smsg->{num};
 	}
+	if (defined($oidbin) && defined($xnum) && blessed($ibx) $ibx->over) {
+		my $smsg = $ibx->over->get_art($xnum);
+		if ($smsg && pack('H*', $smsg->{blob}) eq $oidbin) {
+			carp("BUG: (non-fatal) ".$ibx->eidx_key.
+				" #$xnum $smsg->{blob} still valid");
+			return;
+		}
+	}
 	my $s = 'DELETE FROM xref3 WHERE oidbin = ?';
 	$s .= ' AND ibx_id = ?' if defined($ibx);
 	$s .= ' AND xnum = ?' if defined($xnum);

             reply	other threads:[~2021-10-14  5:49 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-14  5:49 Eric Wong [this message]
2021-10-14  6:06 ` [PATCH v2] extindex: guard against buggy unrefs Eric Wong
2021-10-14 21:09   ` Eric Wong
2021-10-16  1:48     ` [PATCH] extindex: avoid triggering a buggy unref 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=20211014054933.5104-1-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.
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).