]> Sergey Matveev's repositories - public-inbox.git/log
public-inbox.git
3 years agonntp: fix cross-newsgroup Message-ID lookups
Eric Wong [Thu, 10 Sep 2020 09:38:39 +0000 (09:38 +0000)]
nntp: fix cross-newsgroup Message-ID lookups

We cannot blindly use the selected newsgroup for
HEAD/ARTICLE/BODY requests using Message-ID, since
those commands look across all newsgroups; not just
the selected one (if any).

So stuff a reference to the Inbox object into $smsg.
We can reduce args passed into set_nntp_headers() and
msg_hdr_write(), too.

Fixes: 0e6ceff37fc38f28 ("nntp: support slow blob retrievals")
3 years agowwwstream: fix "Atom feed" link
Eric Wong [Wed, 9 Sep 2020 21:38:17 +0000 (21:38 +0000)]
wwwstream: fix "Atom feed" link

Oops, I wanted to stop escaping double-quotes with `qq()' but
used `q()' instead :x

Fixes: 2f61828fcb727e51 ("www: make mirror instructions more prominent")
3 years agocontrib/css: limit <a> coloring to links, only
Eric Wong [Wed, 9 Sep 2020 20:24:55 +0000 (20:24 +0000)]
contrib/css: limit <a> coloring to links, only

We don't want <a> tags without href= attributes to be colored,
since the `<a id=mirror>' tag in the HTML footer is intended
as an anchor destination for `<a href=#mirror>' link at the
top.

3 years agowww: make mirror instructions more prominent
Eric Wong [Tue, 8 Sep 2020 08:29:14 +0000 (08:29 +0000)]
www: make mirror instructions more prominent

In order to fight the misconception that public-inboxes are
centralized, anchor "#mirror" to the clone instructions and
place an emphasis on "mirror", not just cloning.

While we're at it, better describe multi-epoch -V2 inboxes,
since some users do not seem to realize epochs consist of
different data.

3 years agov2writable: reuse read-only shard counting code
Eric Wong [Wed, 2 Sep 2020 11:04:21 +0000 (11:04 +0000)]
v2writable: reuse read-only shard counting code

We'll also fix the read-only code to ensure we notice missing
Xapian shards, since gaps would throw off our expectation that
Xapian document IDs and NNTP article numbers are interchangeable.

3 years agooveridx: document column uses
Eric Wong [Wed, 2 Sep 2020 11:04:20 +0000 (11:04 +0000)]
overidx: document column uses

This may be useful for keeping our heads on straight dealing
with IMAP, NNTP, JMAP, etc.

3 years agowwwaltid: drop unused sqlite3_missing function
Eric Wong [Wed, 2 Sep 2020 11:04:19 +0000 (11:04 +0000)]
wwwaltid: drop unused sqlite3_missing function

It's inlined into the main function, which we'll shorten
slightly with the defined-or (`//') operator.  Also noticed
and fixed a mismatched HTML tag.

3 years agoimap: drop old, pre-Parse::RecDescent search parser
Eric Wong [Wed, 2 Sep 2020 11:04:18 +0000 (11:04 +0000)]
imap: drop old, pre-Parse::RecDescent search parser

We switched to Parse::RecDescent during development and left
some dead code behind.

3 years agosearch: remove {over_ro} field
Eric Wong [Wed, 2 Sep 2020 11:04:17 +0000 (11:04 +0000)]
search: remove {over_ro} field

Only inbox accesses the read-only {over}, now, instead of going
through ->search.  This simplifies our object graph and avoids
potentially redundant FDs and DB handles pointing to the same
over.sqlite3 file.

3 years agosearch: replace ->query with ->mset
Eric Wong [Wed, 2 Sep 2020 11:04:16 +0000 (11:04 +0000)]
search: replace ->query with ->mset

Nearly all of the search uses in the production code rely on
a Xapian mset iterator being returned (instead of an array
of $smsg objects).  So default to returning the mset and move
the burden of smsg array conversion into the test cases.

3 years agotests: add "use strict" and declare v5.10.1 compatibility
Eric Wong [Wed, 2 Sep 2020 11:04:15 +0000 (11:04 +0000)]
tests: add "use strict" and declare v5.10.1 compatibility

strict.pm helped me find a typo in an upcoming recent change, so
ensure we use it since it does more good than harm.  We'll also
take the opportunity here to declare v5.10.1 compatibility level
to future-proof against Perl incompatibilities.

3 years agosearch: remove special case for blank query
Eric Wong [Wed, 2 Sep 2020 11:04:14 +0000 (11:04 +0000)]
search: remove special case for blank query

The special case (if any) belongs at a higher-level,
and this is another step towards removing {over_ro}-dependence
in our Search object.

3 years agouse more idiomatic internal API for ->over access
Eric Wong [Wed, 2 Sep 2020 11:04:13 +0000 (11:04 +0000)]
use more idiomatic internal API for ->over access

{over_ro} being a part of the Search object is a historical
oddity which will go away, soon.  Lets start removing its use in
tests and rarely-used helper scripts.

3 years agodisambiguate OverIdx and Over by field name
Eric Wong [Wed, 2 Sep 2020 11:04:12 +0000 (11:04 +0000)]
disambiguate OverIdx and Over by field name

We'll use {oidx} as the common field name for the read-write
OverIdx, here, to disambiguate it from the read-only {over}
field.  This hopefully makes it clearer which code paths are
read-only and which are read-write.

3 years agomsgmap: note how we use ->created_at
Eric Wong [Wed, 2 Sep 2020 11:04:11 +0000 (11:04 +0000)]
msgmap: note how we use ->created_at

It'll likely be used in the future for JMAP, detached indices,
and maybe other things.

3 years agot/run: Perl future proofing
Eric Wong [Mon, 31 Aug 2020 23:41:56 +0000 (23:41 +0000)]
t/run: Perl future proofing

Bareword file handles outside of STD(IN|OUT|ERR) seem to be on
the chopping block for Perl 8.  We'll also "use v5.10.1" to
guard against future incompatibilities.

3 years agoinit+convert: create non-existing directory hierarchies
Eric Wong [Tue, 1 Sep 2020 01:15:07 +0000 (01:15 +0000)]
init+convert: create non-existing directory hierarchies

Following "git init" as an example, we'll create every parent
path up to the one specified, instead of attempting to continue
on when Cwd::abs_path returns `undef'.

3 years agodoc: remove B<> (bold) markup from the remaining POD
Eric Wong [Tue, 1 Sep 2020 01:15:06 +0000 (01:15 +0000)]
doc: remove B<> (bold) markup from the remaining POD

B<> decreases readability of the POD source and is of dubious
usefulness in the man page.

3 years agowatch: add --help/-h support
Eric Wong [Tue, 1 Sep 2020 01:15:05 +0000 (01:15 +0000)]
watch: add --help/-h support

And avoid unnecessary POD markup in the man page.

3 years agoconfig: use defined-or (//) in a few places
Eric Wong [Tue, 1 Sep 2020 01:15:04 +0000 (01:15 +0000)]
config: use defined-or (//) in a few places

Just some golfing to reduce scrolling and hopefully readability.

3 years agomda+learn: add --help / -h support
Eric Wong [Tue, 1 Sep 2020 01:15:03 +0000 (01:15 +0000)]
mda+learn: add --help / -h support

"use Getopt::Long" doesn't seem too slow on a hot page cache,
and it's probably used frequently enough to be in cache.

We'll also start reducing the amount of markup in the .pod and
favoring verbatim text in documentation for readability in
source form, since the bold text seems excessive.

3 years agodaemon: support --help/-h in -httpd/imapd/nntpd
Eric Wong [Tue, 1 Sep 2020 01:15:02 +0000 (01:15 +0000)]
daemon: support --help/-h in -httpd/imapd/nntpd

For consistency with other commands, though the
protocol-specific options should refer users to
the manpage.

3 years agoscript/*: fold $usage into $help, support `-h' instead of -?
Eric Wong [Tue, 1 Sep 2020 01:15:01 +0000 (01:15 +0000)]
script/*: fold $usage into $help, support `-h' instead of -?

`-h' doesn't conflict with anything, and some users (including
git users) may be more accustomed to using it rather than the
rarely-seen-outside-of-Getopt::Long `-?' switch.

We can also rely on the GetOptions() function to emit a proper
error message instead of just "bad command-line args".

3 years agoedit+purge: support `--help' and `-h' like other commands
Eric Wong [Tue, 1 Sep 2020 01:15:00 +0000 (01:15 +0000)]
edit+purge: support `--help' and `-h' like other commands

And while we're at it, note edit is *destructive* to encourage
reading the fine manual.

3 years agoadmin: improve minimum version text
Eric Wong [Tue, 1 Sep 2020 01:14:59 +0000 (01:14 +0000)]
admin: improve minimum version text

"inboxes 1 inboxes not supported by ..." was non-sensical.
Now it'll show "-V1 inbox not supported by ...", instead.

3 years agoscript/*: set executable bit on -learn and -imapd
Eric Wong [Tue, 1 Sep 2020 01:14:58 +0000 (01:14 +0000)]
script/*: set executable bit on -learn and -imapd

It's useful to mark they're meant to be executable, even
if the shebang is useless.

3 years agot/v2dupindex: test indexing mirrors with duplicate messages
Eric Wong [Tue, 1 Sep 2020 05:55:45 +0000 (05:55 +0000)]
t/v2dupindex: test indexing mirrors with duplicate messages

While it's not a known problem, our deduplicating logic may
change in the future; or a BOFH could be manually injecting
duplicate messages directly into the git epoch repositories.

Ensure indexing in mirrors doesn't break when there's
duplicates.  This is in preparation for detached indices
for multi-inbox search.

3 years agoindex: check for xapian-compact when using --compact
Eric Wong [Tue, 1 Sep 2020 16:54:31 +0000 (16:54 +0000)]
index: check for xapian-compact when using --compact

Otherwise, users may be frustrated to discover it missing
a long indexing run.

3 years agoreplace ParentPipe with EOFpipe
Eric Wong [Mon, 31 Aug 2020 04:41:40 +0000 (04:41 +0000)]
replace ParentPipe with EOFpipe

ParentPipe was a subset of EOFpipe, except EOFpipe correctly
accounts for theoretical(*) spurious wakeups on the pipe.

(*) AFAIK, spurious wakeups are/were more likely on TCP sockets
    due to checksum failures, something that's not a problem on
    local pipes.  We're also not sharing pipes like we do with
    listen sockets on accept(2), so there's no chance of another
    process grabbing bytes (unless we have bugs in our code).

3 years agods: avoid unnecessary timer for waitpid
Eric Wong [Mon, 31 Aug 2020 04:41:39 +0000 (04:41 +0000)]
ds: avoid unnecessary timer for waitpid

It doesn't seem necessary, since we won't call dwaitpid()
until we see an EOF.

3 years agowatch: use EOFpipe to reduce dwaitpid wakeups
Eric Wong [Mon, 31 Aug 2020 04:41:38 +0000 (04:41 +0000)]
watch: use EOFpipe to reduce dwaitpid wakeups

It's a bit inefficient to use a pipe, here.  However, using
dwaitpid() on a process that's not expected to exit soon is
also inefficient as it causes excessive wakeups as most of
our inbox-writing code expects synchronous waitpid().

This only affects -watch instances configured for NNTP and IMAP
clients.

3 years agods: avoid excessive queueing when reaping PIDs
Eric Wong [Mon, 31 Aug 2020 04:41:37 +0000 (04:41 +0000)]
ds: avoid excessive queueing when reaping PIDs

We should not enqueue reap_pids() to run more than once per
EventLoop iteration.  We'll start reformatting reap_pids
to tabs, too, since we're no longer Danga::Socket.

We should also be able to remove timer usage for reaping
down-the-line once we stop abusing dwaitpid() in -watch.

3 years agowatch: comments and tiny cleanups
Eric Wong [Mon, 31 Aug 2020 04:41:36 +0000 (04:41 +0000)]
watch: comments and tiny cleanups

Get rid of an unused variable, prefix a warning and try to
better document control flow around various callbacks.

3 years agowatch: block signals before fork on non-signalfd/kevent systems
Eric Wong [Mon, 31 Aug 2020 04:41:35 +0000 (04:41 +0000)]
watch: block signals before fork on non-signalfd/kevent systems

In case there's non-Linux or BSD users w/o IO::KQueue, we
shouldn't let signal handlers fire in the child processes.

The child processes always assumed signals were blocked by
the parent, so no changes were necessary, there.

3 years agowatch: avoid unnecessary spawning on spam removals
Eric Wong [Mon, 31 Aug 2020 04:41:34 +0000 (04:41 +0000)]
watch: avoid unnecessary spawning on spam removals

This should further mitigate lock contention problems
when -watch is configured to watch on a Maildir for spam
while performing a large NNTP import.

There is now a small risk a message won't get removed because if
it's in the current (uncommitted) fast-import batch, but
unlikely given the batch size is now only 10 messages.

If a that small window is hit, flipping the \Seen flag
(e.g. marking it unread, and then read again) will trigger
another removal attempt via IMAP or Maildir.

3 years agowatch: log signal activities to STDERR
Eric Wong [Mon, 31 Aug 2020 04:41:33 +0000 (04:41 +0000)]
watch: log signal activities to STDERR

Sometimes it may not be apparent when/if a signal is
processed, this hopefully improves the situation.

We'll also change the process title when we're quitting
to better inform users.

3 years agorename WatchMaildir => Watch
Eric Wong [Mon, 31 Aug 2020 04:41:32 +0000 (04:41 +0000)]
rename WatchMaildir => Watch

This is no longer limited to Maildirs now that IMAP and NNTP
support exist; so give it a shorter name.

3 years agowatchmaildir: use v5.10.1, drop warnings
Eric Wong [Mon, 31 Aug 2020 04:41:31 +0000 (04:41 +0000)]
watchmaildir: use v5.10.1, drop warnings

Declare 5.10.1 to avoid potential compatibility problems with
Perl 7/8 down the line.  We'll rely on the command-line to set
or drop warnings during development, at least.

3 years agowatch: limit batch size of NNTP and IMAP workers, too
Eric Wong [Mon, 31 Aug 2020 04:41:30 +0000 (04:41 +0000)]
watch: limit batch size of NNTP and IMAP workers, too

We don't want to monopolize locks because processes can easily
block each other if using `watchspam' on a Maildir while a big
NNTP or IMAP import is happening.

This can also happen if somebody configured a single inbox to
watch from several sources to merge several mailboxes into one
(e.g. both an IMAP and Maildir are watched).

3 years agodoc: expand on indexBatchSize regarding fragmentation
Eric Wong [Mon, 31 Aug 2020 04:33:37 +0000 (04:33 +0000)]
doc: expand on indexBatchSize regarding fragmentation

And change the documentation reference in -tuning to
point to the -index manpage while we're at it.

3 years agoimapd: filter out unusable flags from search
Eric Wong [Sat, 29 Aug 2020 20:32:19 +0000 (20:32 +0000)]
imapd: filter out unusable flags from search

Quiet down logs from -imapd when clients are blindly
sending some unsupported flag conditions (e.g. "DRAFT",
"DELETED") specified in RFC 3501.

3 years agotests: check-run: fixup un-squashed simplification
Eric Wong [Sat, 29 Aug 2020 03:48:39 +0000 (03:48 +0000)]
tests: check-run: fixup un-squashed simplification

Link: https://public-inbox.org/meta/20200828221803.GA89978@dcvr/
3 years agotests: check-run: show skipped tests
Eric Wong [Fri, 28 Aug 2020 10:13:00 +0000 (10:13 +0000)]
tests: check-run: show skipped tests

We'll deduplicate redundant lines and show counts of skipped
tests to ensure it's easy to notice if something is unexpectedly
skipped.

3 years agoimaptracker: update_last: simplify callers
Eric Wong [Fri, 28 Aug 2020 10:12:59 +0000 (10:12 +0000)]
imaptracker: update_last: simplify callers

By making it a no-op if last_uid is not defined.  This isn't a
hot code path, so the extra method dispatch isn't an issue.
It'll save some indentation/wrapping in future commits.

3 years agowatch: flush changes to inbox before updating IMAPTracker
Eric Wong [Fri, 28 Aug 2020 10:12:58 +0000 (10:12 +0000)]
watch: flush changes to inbox before updating IMAPTracker

Data needs to hit inboxes, first.  Otherwise it's possible to
skip messages in case git-fast-import is killed before it sees
"done\n".  Now, -watch will just waste a little bandwidth in
re-downloading a seen message if it's interrupted immediately
before updating IMAPTracker.

3 years agoMakefile.PL: run check-man for <= 80 columns on check-run, too
Eric Wong [Fri, 28 Aug 2020 04:22:00 +0000 (04:22 +0000)]
Makefile.PL: run check-man for <= 80 columns on check-run, too

I mostly use "make check-run" instead of the slower "make check"
target, nowadays, so add this check to ensure the rendered
manpage is always be visible to more users who need big fonts.

3 years agowww: more descriptive pagination
Eric Wong [Thu, 27 Aug 2020 22:05:00 +0000 (22:05 +0000)]
www: more descriptive pagination

Being an easily confused person, I find "next" and "prev"
ambiguous as to whether messages on the next or previous page
will be newer or older than the current page.  Clarify that for
the threaded /$INBOX/ view and search results.

For search results sorted by relevance, we'll use "[>= $SCORE]"
or "[<= $SCORE]" to indicate to indicate directionality.

This also fixes $INBOX/new.html for unindexed v1 inboxes.

3 years agowww: improve navigation around contemporary threads
Eric Wong [Thu, 27 Aug 2020 22:04:59 +0000 (22:04 +0000)]
www: improve navigation around contemporary threads

Sometimes it's useful to quickly get to threads and messages
which are contemporaries of the current thread/message being
focused on.  This hopefully improves navigation by making:

a) the top line (where $INBOX_DIR/description) is shown
   a link to the latest topics in search results and
   per-thread/per-message views.

b) providing a link to contemporaries ("~YYYY-MM-DD") at
   around the thread overview skeleton area for per-thread
   and per-message views

3 years agodoc: watch: expand on NNTP and IMAP-specific knobs
Eric Wong [Thu, 27 Aug 2020 12:17:06 +0000 (12:17 +0000)]
doc: watch: expand on NNTP and IMAP-specific knobs

There's a few more, but maybe they're too esoteric
to be worth documenting at the moment (batch sizes, timeouts, etc).

3 years agodoc: move watch config docs to -watch manpage
Eric Wong [Thu, 27 Aug 2020 12:17:05 +0000 (12:17 +0000)]
doc: move watch config docs to -watch manpage

The -config manpage is a bit long and the -watch stuff is
isolated from the rest of it while we start documenting NNTP and
IMAP support.

I'm not entirely happy with the way IMAP and NNTP are
configured, it's still good enough for small setups.

This also fixes a long-standing misplaced comment about
`publicinboxwatch.spamcheck' affecting all configured inboxes,
that comment was actually for `publicinboxwatch.watchspam'.

We'll omit documenting NNTP for `watchspam', for now, given the
lack of \Seen flags in NNTP and I'm not sure if it's even
useful.  There may not be any newsgroups for sharing confirmed
spam, either...

3 years agowatch: imap: only remove \Seen spam
Eric Wong [Thu, 27 Aug 2020 12:17:04 +0000 (12:17 +0000)]
watch: imap: only remove \Seen spam

This matches the behavior of Maildir `watchspam' handling in not
removing unseen messages.  NNTP can't match this behavior, since
NNTP servers don't store flags, clients do.

3 years agodoc: speling fickses
Eric Wong [Thu, 27 Aug 2020 12:17:03 +0000 (12:17 +0000)]
doc: speling fickses

3 years agodoc: document graceful shutdown signals
Eric Wong [Thu, 27 Aug 2020 12:17:02 +0000 (12:17 +0000)]
doc: document graceful shutdown signals

Same as the read-only daemons.

3 years agooveridx: inline create_ghost sub
Eric Wong [Thu, 27 Aug 2020 12:17:01 +0000 (12:17 +0000)]
overidx: inline create_ghost sub

There's no need for this to be a separate sub since there's
only a single caller.  This saves a few kilobytes at least
in short-lived processes.

3 years agoimaptracker: preserve WAL journal_mode if set by user
Eric Wong [Thu, 27 Aug 2020 12:17:00 +0000 (12:17 +0000)]
imaptracker: preserve WAL journal_mode if set by user

It's no problem for most users to enable WAL, here, since
there's only a single process doing both reading and writing
(unlike the read-only daemons).  However, WAL doesn't work on
network filesystems, so it can't be enabled by default.

3 years agowatchmaildir: ensure I:/W:/E: prefixes in warnings
Eric Wong [Thu, 27 Aug 2020 12:16:59 +0000 (12:16 +0000)]
watchmaildir: ensure I:/W:/E: prefixes in warnings

For consistency in output, any URL/path-context-dependent
prefixes should have the same prefix as the actual warning which
triggered it.

3 years agogit: show more context info on failures
Eric Wong [Thu, 27 Aug 2020 07:51:25 +0000 (07:51 +0000)]
git: show more context info on failures

I'm seeing "read: Connection timed out" from in my syslog from
-httpd.  The fail() calls in PublicInbox::Git seems to be the
only code path of ours which could trigger it...

ETIMEDOUT shouldn't happen on pipes, only sockets; and all of
our socket operations are non-blocking.  So this could be
cgit-wwwhighlight-filter.lua, but that's connecting over
localhost, though on fairly loaded HW.

3 years agosearch: allow testing with current xapian.git and 1.5.x
Eric Wong [Wed, 26 Aug 2020 22:02:57 +0000 (22:02 +0000)]
search: allow testing with current xapian.git and 1.5.x

A `PI_XAPIAN' environment variable is now exposed for testing
purposes.  We'll also deal with the removal of
`NumberValueRangeProcessor' and use `NumberRangeProcessor'
in its place, but continue favoring the old Search::Xapian
since that's all that's packaged for Debian 10.x stable.

3 years agomsgmap: use v5.10.1
Eric Wong [Wed, 26 Aug 2020 08:17:42 +0000 (08:17 +0000)]
msgmap: use v5.10.1

We use the defined-or (`//', `//=') operators in 5.10,
so require 5.10.1 like the rest of our codebase.  Update
an outdated comment while we're at it.

3 years agoover*: use v5.10.1, drop warnings
Eric Wong [Wed, 26 Aug 2020 08:17:41 +0000 (08:17 +0000)]
over*: use v5.10.1, drop warnings

v5.10.1 lets us use the lighter parent.pm instead of base.pm,
and we'll rely on the shebang to enable warnings (or not).

While we're in the area, drop a no-longer-necessary import for
PublicInbox::Search, since OverIdx doesn't require search.

3 years agoover: recent: remove expensive COUNT query
Eric Wong [Wed, 26 Aug 2020 08:17:40 +0000 (08:17 +0000)]
over: recent: remove expensive COUNT query

As noted in commit 87dca6d8d5988c5eb54019cca342450b0b7dd6b7
("www: rework query responses to avoid COUNT in SQLite"),
COUNT on many rows is expensive on big SQLite DBs.

We've already stopped using that code path long ago in WWW
while -imapd and -nntpd never used it.  So we'll adjust our
remaining test cases to not need it, either.

3 years agoover: rename ->disconnect to ->dbh_close
Eric Wong [Wed, 26 Aug 2020 08:17:39 +0000 (08:17 +0000)]
over: rename ->disconnect to ->dbh_close

Since we got rid of over->connect, `disconnect' no longer pairs
with it.  So name it after the `close(2)' syscall it ultimately
issues.

3 years agoover: rename ->connect method to ->dbh
Eric Wong [Wed, 26 Aug 2020 08:17:38 +0000 (08:17 +0000)]
over: rename ->connect method to ->dbh

`->connect' is confused with the perlfunc for the `connect(2)'
syscall, and also `DBI->connect'.  Since SQLite doesn't use
sockets, the word "connect" needlessly confuses me.  Give
it a short name to match the field name we use for it, which
also matches the variable name used by the DBI(3pm) and
DBD::SQLite(3pm) manpages.

3 years agov2writable: compatibility with SWIG Xapian binding
Eric Wong [Tue, 25 Aug 2020 20:26:24 +0000 (20:26 +0000)]
v2writable: compatibility with SWIG Xapian binding

The SWIG binding won't auto-convert IV/UV to PV like the XS
Search::Xapian binding would, so workaround that shortcoming
for now.

Fixes: a367ec1b15a2458 ("mbox: disable "&t" on existing Xapian until full reindex")
3 years agogrok-pull.post_update_hook: flock(2) before SQLite check
Eric Wong [Tue, 25 Aug 2020 10:23:14 +0000 (10:23 +0000)]
grok-pull.post_update_hook: flock(2) before SQLite check

Unlike DBD::SQLite, the sqlite3(1) CLI does not have a default
busy timeout enabled, so it easily times out while acquiring a
SHARED lock for read-only queries.  We can avoid battery-wasting
polling from the SQLite timeout handler by relying on flock(2)
as we do in our Perl code.

Furthermore, this avoids triggering some locking problems[1]
from a long "SELECT COUNT(*) ..." query and reindex.

While there may be other SQLite-related parallelism issues[1],
this works around one of them by relying on flock(2).

[1] https://public-inbox.org/meta/20200825001204.GA840@dcvr/

3 years agoover+msgmap: respect WAL journal_mode if set
Eric Wong [Tue, 25 Aug 2020 03:02:47 +0000 (03:02 +0000)]
over+msgmap: respect WAL journal_mode if set

WAL actually seems to have ideal locking characteristics given
concurrency problems I'm experiencing with --reindex running
in parallel with expensive read-only SQLite queries:
<https://public-inbox.org/meta/20200825001204.GA840@dcvr/>

Unfortunately, we cannot blindly use WAL while preserving
compatibility with existing setups nor our guarantees that
read-only daemons are indeed "read-only".

However, respect an user's the choice to set WAL on their
own if they're comfortable with giving -nntpd/-httpd/-imapd
processes write permission to the directory storing SQLite DBs.

3 years agomsgmap: use "CREATE TABLE IF NOT EXISTS"
Eric Wong [Tue, 25 Aug 2020 03:02:46 +0000 (03:02 +0000)]
msgmap: use "CREATE TABLE IF NOT EXISTS"

It's fewer queries and matches what we do in OverIdx.

3 years agoover: skip nodatacow on the journal
Eric Wong [Tue, 25 Aug 2020 03:02:45 +0000 (03:02 +0000)]
over: skip nodatacow on the journal

This file gets truncated anyhow, so it won't fragment.

3 years agodoc: 1.6.0 release notes update
Eric Wong [Tue, 25 Aug 2020 10:51:29 +0000 (10:51 +0000)]
doc: 1.6.0 release notes update

A few more things happened, here.

3 years agodoc: add some more tuning notes
Eric Wong [Tue, 25 Aug 2020 10:51:20 +0000 (10:51 +0000)]
doc: add some more tuning notes

I've learned a thing or three about btrfs in the past few
weeks and remembered some old HDD things, too.

The Xapian MultiDatabase problem will need to be addressed
for 1.7...

3 years agosearchidx: croak for Xapian DB open failure
Eric Wong [Sun, 23 Aug 2020 21:00:27 +0000 (21:00 +0000)]
searchidx: croak for Xapian DB open failure

croak() can give more context on the failure, and setting
`PERL5OPT=-MCarp=verbose' can force a stacktrace.

3 years agoexamples: add imapd systemd examples
Eric Wong [Sun, 23 Aug 2020 07:49:18 +0000 (07:49 +0000)]
examples: add imapd systemd examples

We've got examples for all the other daemons, too!

3 years agoindex: --sequential-shard checkpoints after each shard
Eric Wong [Sat, 22 Aug 2020 19:51:36 +0000 (19:51 +0000)]
index: --sequential-shard checkpoints after each shard

There's no reason we'd want Xapian to defer flushing once we've
indexed everything belonging to a particular shard.

3 years agombox: disable "&t" on existing Xapian until full reindex
Eric Wong [Sat, 22 Aug 2020 06:06:27 +0000 (06:06 +0000)]
mbox: disable "&t" on existing Xapian until full reindex

Expanding threads via over.sqlite3 for mbox.gz downloads without
Xapian effectively collapsing on the THREADID column leads to
repeated messages getting downloaded.

To avoid that situation, use a "has_threadid" Xapian metadata
flag that's only set on --reindex (and brand new Xapian DBs).

This allows admins to upgrade WWW or do --reindex in any order;
without worrying about users eating up bandwidth and CPU cycles.

3 years agosearch: support downloading mboxes results with full thread
Eric Wong [Sat, 22 Aug 2020 06:06:26 +0000 (06:06 +0000)]
search: support downloading mboxes results with full thread

Finally, the addition of THREADID for collapsing results
in Xapian lets us emulate the "mairix --threads" feature.
That is, instead of returning only the matching messages,
the entire thread is included in the downloaded mbox.gz

This requires a "public-inbox-index --reindex" to be usable.

3 years agosearchidx: index THREADID in Xapian
Eric Wong [Sat, 22 Aug 2020 06:06:25 +0000 (06:06 +0000)]
searchidx: index THREADID in Xapian

This is the `tid' column from over.sqlite3; and will be used for
IMAP and JMAP search (among other things).

3 years agosearchidx: put all shard-related stuff in SearchIdxShard.pm
Eric Wong [Sat, 22 Aug 2020 06:06:24 +0000 (06:06 +0000)]
searchidx: put all shard-related stuff in SearchIdxShard.pm

We'll also rename the /^remote_/ prefix to "shard_", since
remote implies the process is on a different host.  These
methods only pass messages to a child process on the same host
OR perform operations within the same process.

3 years agosearchidxshard: clear $msgref buffer properly
Eric Wong [Sat, 22 Aug 2020 06:06:23 +0000 (06:06 +0000)]
searchidxshard: clear $msgref buffer properly

Merely assigning `undef' to a scalar does not free the
underlying buffer memory of a scalar.

3 years agosearchview: fix mbox.gz downloads for lynx users
Eric Wong [Sat, 22 Aug 2020 00:41:25 +0000 (00:41 +0000)]
searchview: fix mbox.gz downloads for lynx users

Unlike w3m and links, the lynx browser seems to require a `name'
attribute for `<input type=submit>' elements.  Maybe some other
browsers do, too.  The `name' attribute for submit elements
doesn't seem to cause any harm for w3m or links, users, either;
despite not (AFAIK) being part of historical or current HTML
specs.

3 years agosearch: add mset_to_artnums method
Eric Wong [Thu, 20 Aug 2020 20:24:57 +0000 (20:24 +0000)]
search: add mset_to_artnums method

We can avoid importing mdocid() in several places by using
this method, simplifying callers.

3 years agoinit+index: support --skip-docdata for Xapian
Eric Wong [Thu, 20 Aug 2020 20:24:56 +0000 (20:24 +0000)]
init+index: support --skip-docdata for Xapian

Since we no longer read document data from Xapian, allow users
to opt-out of storing it.

This breaks compatibility with previous releases of
public-inbox, but gives us a ~1.5% space savings on Xapian
storage (and associated I/O and page cache pressure reduction).

3 years agot/nntpd-v2: set PI_TEST_VERSION=2 properly
Eric Wong [Thu, 20 Aug 2020 20:24:55 +0000 (20:24 +0000)]
t/nntpd-v2: set PI_TEST_VERSION=2 properly

Numbers are hard :<

3 years agosmsg: remove from_mitem
Eric Wong [Thu, 20 Aug 2020 20:24:54 +0000 (20:24 +0000)]
smsg: remove from_mitem

We no longer read docdata.glass from anywhere in our code base.

Some adjustments were needed to t/search.t to deal with the
Xapian::WritableDatabase committing at different times, since
our ->query is avoided from PublicInbox::SearchIdx to avoid
needing a {over_ro} field.

3 years agombox: avoid Xapian docdata in search results
Eric Wong [Thu, 20 Aug 2020 20:24:53 +0000 (20:24 +0000)]
mbox: avoid Xapian docdata in search results

Another place where we can reduce kernel page cache overhead
by hitting over.sqlite3 instead of docdata.glass.

3 years agoextmsg: avoid using Xapian docdata
Eric Wong [Thu, 20 Aug 2020 20:24:52 +0000 (20:24 +0000)]
extmsg: avoid using Xapian docdata

Once again, over.sqlite3 contains everything necessary for
Message-ID resolution.  Also, Xapian may be completely
unnecessary with the advent of over.sqlite3, but that's for
another time.

3 years agosearchview: convert nested and Atom display to over.sqlite3
Eric Wong [Thu, 20 Aug 2020 20:24:51 +0000 (20:24 +0000)]
searchview: convert nested and Atom display to over.sqlite3

git blob retrieval dominates on these, "&x=t" (nested) is
roughly the same due to increased overhead for ->get_percent
storage balancing out the mass-loading from SQLite.

Atom "&x=A" is sped up slightly and uses less memory in the
long-lived response.

3 years agosearchview: speed up search summary by ~10%
Eric Wong [Thu, 20 Aug 2020 20:24:50 +0000 (20:24 +0000)]
searchview: speed up search summary by ~10%

Instead of loading one article at-a-time from over.sqlite3, we
can use SQL to mass-load IN (?,?, ...) all results with a single
SQLite query.  Despite SQLite being in-process and having no
network latency, the reduction in SQL query executions from
loading multiple rows at once speeds things up significantly.

We'll keep the over->get_art optimizations from the previous
commit, since it still speeds up long-lived responses, slightly.

3 years agosearchview: use over.sqlite3 instead of Xapian docdata
Eric Wong [Thu, 20 Aug 2020 20:24:49 +0000 (20:24 +0000)]
searchview: use over.sqlite3 instead of Xapian docdata

This is a step towards improving kernel page cache hit rates by
relying on over.sqlite3 for document data instead of Xapian.
Some micro-optimization to over->get_art was required to
maintain performance.

3 years agosmsg: reduce utf8::decode call sites
Eric Wong [Thu, 20 Aug 2020 20:24:48 +0000 (20:24 +0000)]
smsg: reduce utf8::decode call sites

Both callers of load_from_data call utf8::decode, so just
do utf8::decode in load_from_data.

3 years agosearch: make qparse_new an internal function
Eric Wong [Thu, 20 Aug 2020 20:24:47 +0000 (20:24 +0000)]
search: make qparse_new an internal function

We'll probably be reusing it from another package in a future commit.

3 years agosearchquery: split off from searchview
Eric Wong [Thu, 20 Aug 2020 20:24:46 +0000 (20:24 +0000)]
searchquery: split off from searchview

Since this was already a separate package, split it off
into its own file since SearchView may not handle inbox
groups.

3 years agosearch: export mdocid subroutine
Eric Wong [Thu, 20 Aug 2020 20:24:45 +0000 (20:24 +0000)]
search: export mdocid subroutine

No need to have awkward globrefs for this.

3 years agosearch: improve comments around constants
Eric Wong [Thu, 20 Aug 2020 20:24:44 +0000 (20:24 +0000)]
search: improve comments around constants

We'll probably be adding more value columns like THREADID to sort
on.

3 years agowww: reduce long-lived PublicInbox::Search references
Eric Wong [Thu, 20 Aug 2020 20:24:43 +0000 (20:24 +0000)]
www: reduce long-lived PublicInbox::Search references

While this is unlikely to be a problem in current practice,
keeping Xapian DBs open for long responses can interfere with
free space recovery after -compact.

In the future, it will interfere with inbox search grouping
and lead to unexpected results.

3 years agoxapcmd: simplify {reindex} parameter passing
Eric Wong [Thu, 20 Aug 2020 20:24:42 +0000 (20:24 +0000)]
xapcmd: simplify {reindex} parameter passing

No need to localize it, here, since we can just refer to it
in the `$opt' hashref.  Hopefully this improves readability
for others like it does for me.

I sometimes wonder if the concept of a stack in high-level
languages is even necessary...

3 years agosearch: v2: ensure shards are numerically sorted
Eric Wong [Thu, 20 Aug 2020 20:24:41 +0000 (20:24 +0000)]
search: v2: ensure shards are numerically sorted

This seems required to correctly get the NNTP article number
from Xapian docid on combined Xapian DBs.  The default
(ASCII-betical) sorting was only acceptable for -imapd users
until somebody hit 11 (or more) shards, which is a rare case.

3 years agoinit: drop -N alias for --skip-artnum
Eric Wong [Thu, 20 Aug 2020 20:24:40 +0000 (20:24 +0000)]
init: drop -N alias for --skip-artnum

It may be too easily confused for --newsgroup or --ng.  This is
too rarely used and never made it into a release, so it should
be fine.

3 years agoinit: support --newsgroup option
Eric Wong [Thu, 20 Aug 2020 20:24:39 +0000 (20:24 +0000)]
init: support --newsgroup option

We can reduce the need to edit the config file for NNTP group names
this way.

3 years agoinit: support --help and -?
Eric Wong [Thu, 20 Aug 2020 20:24:38 +0000 (20:24 +0000)]
init: support --help and -?

And speed those up with some lazy loading, too.

3 years agocompact: support --help/-? and perform lazy loading
Eric Wong [Thu, 20 Aug 2020 20:24:37 +0000 (20:24 +0000)]
compact: support --help/-? and perform lazy loading

This probably won't be used much, but --help can still
make sense.