user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
thread overview below | download mbox.gz: |
* [PATCH] searchidx: improve error message when Xapian fails
  @ 2019-06-12  0:18 14%         ` Eric Wong
  0 siblings, 0 replies; 1+ results
From: Eric Wong @ 2019-06-12  0:18 UTC (permalink / raw)
  To: Konstantin Ryabitsev; +Cc: meta

Konstantin Ryabitsev <konstantin@linuxfoundation.org> wrote:
> > Exception: Expected block 102325 to be level 2, not 0
> 
> In the process of helping me debug this, Eric pointed out that the
> xapian-db was corrupted. Apparently, this happened while I was copying
> the lkml dir to a safe location for testing purposes. Once I had a
> non-corrupted version of the database, I was able to successfully edit
> the necessary message.

Also, for public reference, using the flock(1) command (or
similar) can be used to safely copy while -mda or -watch
runs:

	flock /path/to/inbox.lock cp -a ....

I suppose this is also possible, to minimize lock time:

	# unlocked copy step
	rsync -a $SRC $DST

	# locked copy using a remote destination to force delta-transmission:
	flock /path/to/inbox.lock rsync -a $SRC $REMOTE_DST

But to make Xapian corruption more apparent in the future:

---------------8<-------------
Subject: [PATCH] searchidx: improve error message when Xapian fails

Make it easier to detect if a partition is corrupt.
---
 lib/PublicInbox/SearchIdx.pm | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/lib/PublicInbox/SearchIdx.pm b/lib/PublicInbox/SearchIdx.pm
index 9985628..7cd67f1 100644
--- a/lib/PublicInbox/SearchIdx.pm
+++ b/lib/PublicInbox/SearchIdx.pm
@@ -117,7 +117,11 @@ sub _xdb_acquire {
 		}
 	}
 	return unless defined $flag;
-	$self->{xdb} = Search::Xapian::WritableDatabase->new($dir, $flag);
+	my $xdb = eval { Search::Xapian::WritableDatabase->new($dir, $flag) };
+	if ($@) {
+		die "Failed opening $dir: ", $@;
+	}
+	$self->{xdb} = $xdb;
 }
 
 sub add_val ($$$) {
-- 
EW

^ permalink raw reply related	[relevance 14%]

Results 1-1 of 1 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2019-06-09  2:51     [PATCH 00/11] v2: implement message editing Eric Wong (Contractor, The Linux Foundation)
2019-06-10 15:06     ` Konstantin Ryabitsev
2019-06-10 15:40       ` Eric Wong
2019-06-10 18:57         ` Konstantin Ryabitsev
2019-06-11 21:06           ` Konstantin Ryabitsev
2019-06-12  0:18 14%         ` [PATCH] searchidx: improve error message when Xapian fails Eric Wong

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).