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-ASN: 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 28F101F670 for ; Thu, 14 Oct 2021 05:49:33 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH] extindex: guard against buggy unrefs Date: Thu, 14 Oct 2021 05:49:33 +0000 Message-Id: <20211014054933.5104-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: 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);