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 09/10] extindex: SIGUSR1 supports checkpoint
Date: Sat,  7 Nov 2020 10:56:59 +0000	[thread overview]
Message-ID: <20201107105700.12586-10-e@80x24.org> (raw)
In-Reply-To: <20201107105700.12586-1-e@80x24.org>

Matching the behavior of git-fast-import(1), we'll allow a user
to send SIGUSR1 to checkpoint over.sqlite3 and Xapian.
---
 lib/PublicInbox/ExtSearchIdx.pm | 23 ++++++++++++-----------
 script/public-inbox-extindex    |  1 +
 2 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/lib/PublicInbox/ExtSearchIdx.pm b/lib/PublicInbox/ExtSearchIdx.pm
index 50342802..7aaf8291 100644
--- a/lib/PublicInbox/ExtSearchIdx.pm
+++ b/lib/PublicInbox/ExtSearchIdx.pm
@@ -284,16 +284,9 @@ sub last_commits {
 }
 
 sub _sync_inbox ($$$) {
-	my ($self, $opt, $ibx) = @_;
-	my $sync = {
-		need_checkpoint => \(my $bool = 0),
-		reindex => $opt->{reindex},
-		-opt => $opt,
-		self => $self,
-		ibx => $ibx,
-		nr => \(my $nr = 0),
-		-regen_fmt => "%u/?\n",
-	};
+	my ($self, $sync, $ibx) = @_;
+	$sync->{ibx} = $ibx;
+	$sync->{nr} = \(my $nr = 0);
 	my $v = $ibx->version;
 	my $ekey = $ibx->eidx_key;
 	if ($v == 2) {
@@ -324,10 +317,18 @@ sub eidx_sync { # main entry point
 	local $SIG{__WARN__} = sub {
 		$warn_cb->($self->{current_info}, ': ', @_);
 	};
+	my $sync = {
+		need_checkpoint => \(my $need_checkpoint = 0),
+		reindex => $opt->{reindex},
+		-opt => $opt,
+		self => $self,
+		-regen_fmt => "%u/?\n",
+	};
+	local $SIG{USR1} = sub { $need_checkpoint = 1 };
 
 	# don't use $_ here, it'll get clobbered by reindex_checkpoint
 	for my $ibx (@{$self->{ibx_list}}) {
-		_sync_inbox($self, $opt, $ibx);
+		_sync_inbox($self, $sync, $ibx);
 	}
 
 	$self->{oidx}->rethread_done($opt);
diff --git a/script/public-inbox-extindex b/script/public-inbox-extindex
index bb1e174a..864a2732 100644
--- a/script/public-inbox-extindex
+++ b/script/public-inbox-extindex
@@ -33,6 +33,7 @@ die "--jobs must be >= 0\n" if defined $opt->{jobs} && $opt->{jobs} < 0;
 
 # require lazily to speed up --help
 my $eidx_dir = shift(@ARGV) // die "E: $help";
+local $SIG{USR1} = 'IGNORE'; # to be overridden in eidx_sync
 require PublicInbox::Admin;
 my $cfg = PublicInbox::Config->new;
 my @ibxs = PublicInbox::Admin::resolve_inboxes(\@ARGV, $opt, $cfg);

  parent reply	other threads:[~2020-11-07 10:57 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-07 10:56 [PATCH 00/10] extindex: another round of updates Eric Wong
2020-11-07 10:56 ` [PATCH 01/10] extsearch: rename -eindex to -extindex Eric Wong
2020-11-07 10:56 ` [PATCH 02/10] extsearchidx: avoid needless alternates rewrite in ALL.git Eric Wong
2020-11-07 10:56 ` [PATCH 03/10] searchidxshard: reduce syscalls when writing ->eidx_key Eric Wong
2020-11-07 10:56 ` [PATCH 04/10] searchidxshard: further improve {current_info} readability Eric Wong
2020-11-07 10:56 ` [PATCH 05/10] v2writable: less expensive checkpoint for extindex Eric Wong
2020-11-07 10:56 ` [PATCH 06/10] extsearchidx: quiet warning for unindexed `d' messages Eric Wong
2020-11-07 10:56 ` [PATCH 07/10] extsearch: canonicalize topdir Eric Wong
2020-11-07 10:56 ` [PATCH 08/10] v2writable: more accurate {current_info} warnings/progress Eric Wong
2020-11-07 10:56 ` Eric Wong [this message]
2020-11-07 10:57 ` [PATCH 10/10] extindex: fix --batch-size support 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=20201107105700.12586-10-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).