As a example for an simple tcp health check the health-check.sh script
is added. It closes the connection after 10 seconds and only answer to
"PING\n" with a "PONG\n". It is installed by default next to the script
executable.
Markus Valentin [Wed, 19 Jun 2019 12:36:12 +0000 (14:36 +0200)]
script: add a parameter -p for passthrough scripts
Adding the passthrough option to script, this allows to configure a
script to be straightly called from a socket connection, without
implementing any specific protocol.
Timo Sirainen [Mon, 10 Jun 2019 20:07:56 +0000 (23:07 +0300)]
lib-index: Compress cache immediately after enough mails have been expunged
This fixes a bug where cache may never become compressed in certain mailbox
access patterns. Especially for autoexpunging in lazy_expunge mailboxes.
The cache compression happened only when:
a) After the mailbox_sync() that finishes expunging there was another
mailbox_sync(). If mailbox was immediately closed after expunging, this
didn't happen.
b) Fields are fetched from cache
If neither of these happened, the cache just kept growing. This happened
especially with lazy_expunge mailboxes.
sdbox format was always doing b) during expunging, because it looked up
GUIDs from cache. However, this helped only with regular expunges, not
with autoexpunges, because autoexpunging didn't finish with any
mailbox_sync() (which is a bug on its own).
mdbox also did GUID lookups from cache, but it wasn't doing cache
compressions due the bug fixed by the previous commit.
Timo Sirainen [Mon, 10 Jun 2019 20:01:16 +0000 (23:01 +0300)]
lib-index: Fix calling expunge handlers with mdbox
This fixes updating deleted_record_count in dovecot.index.cache files.
Because they were wrong, the cache wasn't always compressed as early as
it should have been.
mdbox uses a separate transaction to commit expunges while mailbox is being
synced. When syncing was finished, tail_offset was updated too early so
mail_index_map(MAIL_INDEX_SYNC_HANDLER_FILE) was always a no-op and expunge
handlers were never called.
There doesn't seem to be any downside to not updating tail_offset early.
sdbox saving also uses such a transaction, but there is no difference in
the resulting dovecot.index.log file. The main worry I had was that
tail_offset wouldn't be updated to point to the end of the log file.
However, this doesn't happen with the old code either. This is because the
extra transaction is external, and tail_offset updating skips over all
external transactions anyway.
This allows accessing the global mail storage service. Normally there is
only a single service created for the process at a time, so this allows
accessing it.
Markus Valentin [Thu, 13 Jun 2019 18:54:39 +0000 (20:54 +0200)]
lmtp-proxy: set real_ variables in auth_user_info struct
Set the real_ variables from connection to the client struct and from
there to the auth_user_info. This allows to pass the real_ variables to
lib-auth and thereby to the auth process.
Markus Valentin [Thu, 13 Jun 2019 18:45:55 +0000 (20:45 +0200)]
lib-auth: add real_[remote|local]_[ip|port] to auth_user_info
This allows the auth_user_info_export function to export all the real_
variables, if available, to the auth request thereby enableing real_
variables for lib-auth.
stats: event export - Increase default http-post timeout to 250ms
50ms just isn't enough. A slightly higher latency link combined with a
handful of storage I/Os can easily use up 50ms.
If each event has approximately 4kB memory footprint, then a 250ms timeout
keeps the memory requirement relatively low (50MB on average / 200MB max at
50k events/sec) but still allows a decent amount of time for the HTTP POST
to get sent to and processed by a server in the same datacenter.
Timo Sirainen [Wed, 12 Jun 2019 07:58:37 +0000 (10:58 +0300)]
lib-storage: Sync mailbox after autoexpunging
This actually finishes expunging the mails. Previously the mails were
just marked to be expunged in the transaction log, and the next session
that opened the mailbox finished the expunging.
Timo Sirainen [Tue, 5 Feb 2019 22:17:52 +0000 (14:17 -0800)]
lib-index: Make sure tail_offset is updated after calling expunge handlers
Since it's a bit troublesome to track whether expunge handlers were actually
called, we can just assume that as long as syncing sees expunges, they were
called (and thet most likely were).
This fixes a bug where dovecot.index.cache header's record_count kept
shrinking and deleted_record_count kept increasing after each sync.
These values were only used to determine when to compress the cache, so
its only effect was that the cache could have been compressed earlier
than necessary.
If header with the same key already exists, just replace the value.
HTTP supports having multiple headers with the same key only when they
can be rewritten into a single comma-separated header. So practically
there's no reason for lib-http to need to support adding multiple
headers. Replacing an existing value is more useful generally.
Aki Tuomi [Fri, 19 Apr 2019 17:39:32 +0000 (20:39 +0300)]
lib-dict: dict-sql - Add username as parameter
SQL statement caching works better when the username is provided
as parameter instead of part of the query, since the caching
can now cache same statements despite username changes.
The previous code always assumed it would be called from another thread, but
due to race conditions this wasn't true always. The lookup could have
already finished by the time cass_future_set_callback() was called, in which
case it called the callback immediately.
If the callback was called from the main thread, it still wrote to the
fd_pipe. Because this was a blocking write, it was possible that the pipe
ended becoming full, which caused the whole dict process to hang.
The core event exporter feature. It extends the metric { } config blocks
and adds new event_exporter { } blocks.
event_exporter EXNAME {
format = FMT # required, see below
format_args = FMTARGS # optional, see below
transport = TRANSPORT # required, see below
transport_args = TRANSPORTARGS # optional, see below
}
metric METNAME {
... normal metric fields ...
exporter = EXNAME # required to make export happen
exporter_include = INCS # optional, see below
}
FMT is a string identifying which format to serialize the event into. As of
this commit, the only valid value is "none" (always the empty string).
FMTARGS is a set of tokens that tweak how certain data types are encoded. If
not specified, the format's default is used ("none" always emits empty strings
so it doesn't care what this is set to, future formats will make use of this
setting). Currently the only possible tokens are: "time-rfc3339" and
"time-unix" - as their names imply, they format all timestamps as either
RFC3339 or Unix-style seconds since 1970-01-01 00:00:00 UTC.
TRANSPORT is a string identifying how to transport the serialized event. As
of this commit, the only valid value is "drop" which simply drops the event.
TRANSPORTARGS is a string used by the transport to tweak its behavior. The
drop transport ignores the args.
INCS is a string made up of tokens ("name", "hostname", "timestamps",
"categories", and "fields") which control what parts of an event are
exported. It can be set to any set of those (including empty set) and the
order doesn't matter. It defaults to all 5 tokens.
At times, we want to simplify the structure of events before sending them to
the stats process thereby minimizing the amount of data transfered and the
amount of work the stats process has to do. This simplification before
sending allows us to incur the CPU penalty in the (many) sending processes
instead of in the (sole & single-threaded) stats process.
Unlike the code in lib-master, this implementation flattens part of the
parent chain backwards so that parents' fields are properly overridden by
their children. It exists in lib because it shares code with the recently
added event_flatten().
Timo Sirainen [Fri, 10 May 2019 15:06:46 +0000 (18:06 +0300)]
lib: Make sure uncorking ostream-file flushes network output immediately
TCP_CORK and TCP_NODELAY are separate things, but we'll treat them similarly
for our ostream corking API. It was always intended that all data written
inside corking would be delayed until uncork, and immediately sent
afterwards.
This change removes unnecessary extra 40ms delays, which may happen when
proxying.
Aki Tuomi [Fri, 10 May 2019 12:55:22 +0000 (15:55 +0300)]
doveadm-dsync: Always cleanup after connection
Go through the same error handling path every time. Fixes
Panic: file ioloop.c: line 826 (io_loop_destroy): assertion failed: (ioloop == current_ioloop)
This happened because the ioloop wasn't destroyed
on error.
Timo Sirainen [Fri, 10 May 2019 16:16:07 +0000 (19:16 +0300)]
lib-storage: Attachment flag detection shouldn't cause mail body to be opened
Fetching cached mail headers with
mail_attachment_detection_options=add-flags-on-save caued IMAP BODYSTRUCTURE
to be fetched as well. If it wasn't already cached, this caused opening the
mail body to generate it. Also the result wasn't added to cache, so the
inefficient behavior continued.
Timo Sirainen [Thu, 9 May 2019 16:48:43 +0000 (19:48 +0300)]
doveadm dict: Make it clear that *iter_flags can't dereference NULL pointer
It's not possible to dereference it anyway, because only "doveadm dict iter"
has these iter parameters. This change fixes warnings from static analyzers.
Timo Sirainen [Thu, 9 May 2019 12:29:34 +0000 (15:29 +0300)]
global: Change CALLBACK_TYPECHECK() to used with subtraction
This is because clang's -Wstring-plus-int gave warnings when using
"string" + CALLBACK_TYPECHECK(), but there are no warnings when using
"string" - CALLBACK_TYPECHECK(). It would have been enough to change
only the string parameters to use "-", but for consistency this commit
changes all of them.