From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 9/9] searchidxshard: simplify newline elimination
Date: Tue, 15 Dec 2020 02:02:24 +0000 [thread overview]
Message-ID: <20201215020224.11739-10-e@80x24.org> (raw)
In-Reply-To: <20201215020224.11739-1-e@80x24.org>
This overdue change fixes {current_info} to not inject a newline
into every warning message.
Simpler code helps us avoid bugs and the need to make
fixes like commit 44de182766037948d62bc2a8ba924de2264dd5fc
("searchidxshard: chomp $eidx_key from pipe").
---
lib/PublicInbox/SearchIdxShard.pm | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/lib/PublicInbox/SearchIdxShard.pm b/lib/PublicInbox/SearchIdxShard.pm
index ee00858b..2e654769 100644
--- a/lib/PublicInbox/SearchIdxShard.pm
+++ b/lib/PublicInbox/SearchIdxShard.pm
@@ -69,33 +69,31 @@ sub shard_worker_loop ($$$$$) {
$0 = "shard[$shard]";
$self->begin_txn_lazy;
while (my $line = readline($r)) {
+ chomp $line;
$v2w->{current_info} = "[$shard] $line";
- if ($line eq "commit\n") {
+ if ($line eq 'commit') {
$self->commit_txn_lazy;
- } elsif ($line eq "close\n") {
+ } elsif ($line eq 'close') {
$self->idx_release;
- } elsif ($line eq "barrier\n") {
+ } elsif ($line eq 'barrier') {
$self->commit_txn_lazy;
# no need to lock < 512 bytes is atomic under POSIX
print $bnote "barrier $shard\n" or
die "write failed for barrier $!\n";
- } elsif ($line =~ /\AD ([0-9]+)\n\z/s) {
+ } elsif ($line =~ /\AD ([0-9]+)\z/s) {
$self->remove_by_docid($1 + 0);
} elsif ($line =~ s/\A\+X //) {
my ($len, $docid, $eidx_key) = split(/ /, $line, 3);
- chomp $eidx_key;
$self->add_eidx_info($docid, $eidx_key, eml($r, $len));
} elsif ($line =~ s/\A-X //) {
my ($len, $docid, $eidx_key) = split(/ /, $line, 3);
- chomp $eidx_key;
$self->remove_eidx_info($docid, $eidx_key,
eml($r, $len));
- } elsif ($line =~ s/\AO ([^\n]+)\n//) {
+ } elsif ($line =~ s/\AO ([^\n]+)//) {
my $over_fn = $1;
$over_fn =~ tr/\0/\n/;
$self->over_check(PublicInbox::Over->new($over_fn));
} else {
- chomp $line;
my $eidx_key;
if ($line =~ s/\AX=(.+)\0//) {
$eidx_key = $1;
next prev parent reply other threads:[~2020-12-15 2:02 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-11 3:37 [PATCH] extindex: preliminary --reindex support Eric Wong
2020-12-12 19:53 ` [PATCH 2/1] extindex: reindex: drop stale rows from over.sqlite3 Eric Wong
2020-12-15 2:02 ` [PATCH 0/9] extindex: --reindex support Eric Wong
2020-12-15 2:02 ` [PATCH 1/9] extindex: preliminary " Eric Wong
2020-12-15 2:02 ` [PATCH 2/9] extindex: delete stale messages from over.sqlite3 Eric Wong
2020-12-15 2:02 ` [PATCH 3/9] over: sort xref3 by xnum if ibx_id repeats Eric Wong
2020-12-15 2:02 ` [PATCH 4/9] extindex: support --rethread and content bifurcation Eric Wong
2020-12-15 2:02 ` [PATCH 5/9] extsearchidx: reindex works on Xapian, too Eric Wong
2020-12-15 2:02 ` [PATCH 6/9] extsearchidx: checkpoint releases locks Eric Wong
2020-12-15 2:02 ` [PATCH 7/9] extsearchidx: simplify reindex code paths Eric Wong
2020-12-15 2:02 ` [PATCH 8/9] extsearchidx: reindex releases over.sqlite3 handles properly Eric Wong
2020-12-15 2:02 ` Eric Wong [this message]
2020-12-16 6:40 ` [PATCH 0/9] extindex: --reindex support Eric Wong
2020-12-16 23:04 ` [PATCH 10/9] extsearchidx: lock eidxq on full --reindex 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=20201215020224.11739-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).