about summary refs log tree commit homepage
path: root/lib/PublicInbox/ExtSearchIdx.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2021-10-14 06:06:29 +0000
committerEric Wong <e@80x24.org>2021-10-14 09:07:08 +0000
commitc485036d0b1ce7ed94ea02f84a8a5cd86144ad02 (patch)
treeec91cdd1133316ed7b6fad636ace6f55b9a9848c /lib/PublicInbox/ExtSearchIdx.pm
parent3dc766ffb925d8c255a109d633fa5c4702c1fe23 (diff)
downloadpublic-inbox-c485036d0b1ce7ed94ea02f84a8a5cd86144ad02.tar.gz
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.
Diffstat (limited to 'lib/PublicInbox/ExtSearchIdx.pm')
-rw-r--r--lib/PublicInbox/ExtSearchIdx.pm9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/PublicInbox/ExtSearchIdx.pm b/lib/PublicInbox/ExtSearchIdx.pm
index 750ced5c..3d7a6e7d 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);