Skip to content

todo proc.8

Manvendra Bhangui edited this page Feb 25, 2024 · 6 revisions

NAME

todo-proc - process todo messages from the queue

SYNOPSIS

todo-proc [ -s] | [-c]-d

DESCRIPTION

todo-proc handles todo messages placed into the outgoing queue by qmail-queue. todo-proc by default looks at /var/indimail/queue for messages. This path can be changed by defining the QUEUEDIR environment variable.

todo-proc addresses a problem known as the silly qmail (queue) problem. This problem is found only on system with high injection rates. qmail with a big local and remote concurrency could deliver a tremendous amount of messages but normally this can not be achieved because qmail-send becomes a bottleneck on those high volumes servers. qmail-send preprocesses all new messages before distributing them for local or remote delivering. In one run qmail-send does one todo run but has the ability to close multiple jobs. Because of this layout qmail-send can not feed all the new available (local/remote) delivery slots and therefor it is not possible to achieve the maximum throughput. This would be a minor problem if one qmail-send run could be done in extreme short time. But because of many file system calls (fsync and (un)link) a todo run is expensive and throttles the throughput. todo-proc solves this by having the todo run done by itself rather than by qmail-send. This reduces the run time for qmail-send.

todo-proc prepares incoming messages for local and remote deliveries (by creating info/<messid> local/<messid> and remote/<messid> and removing todo/<messid>. See also indimail-mta-internals(7). Next todo-proc transmits the <messid> to qmail-send which will add this message into the priority queue thus scheduling the message for delivery. todo-proc can be optimized further by making it to transmit the <messids> in chunks rather than every time a file is found in todo directory. The chunk size can be set by defining TODO_CHUNK_SIZE. todo-proc will wait for CHUNK_WAIT seconds (set by environment variable CHUNK_WAIT) before transmitting accumulated all <messids> to qmail-send. You can keep TODO_CHUNK_SIZE low (1 is the minimum) to schedule the message immediately for delivery as soon as it comes into the queue. You can keep it large to optimize IO performance.

todo-proc can work in two modes - static queue mode or dynamic queue mode. The dynamic queue mode is enabled when passed the -d argument by qscheduler(8).

In dynamic queue mode, todo-proc wakes up on a message from qmail-queue(8). If the environment variable DYNAMIC_QUEUE is set, qmail-queue(8) uses message queue /qmail-queue. If there is any failure using message queues, qmail-queue(8) reverts back to using QUEUE/lock/trigger. When in dynamic queue mode, todo-proc(8) will also respond to qmail-queue running in static mode whhere communications happens through QUEUE/lock/trigger. Here QUEUE refers to the base path of the queue. e.g. /var/indimail/queue/queue1.

In static queue mode, todo-proc normally does a queue run for every injected message and then transmits the <messid> to qmail-send which schedules it for local/remote delivery. If we get too many injections the queue runs will stall scheduling of local/remote deliveries. Usually we see a sharp drop in concurrent deliveries while new messages arrive at high rate in the queue. In such a situation it doesn't make sense to process the queue after each and every injection. It is more important to fill the delivery slots with work to drain the queue. The todo run can be adjusted by setting the environment variable TODO_INTERVAL to have only one queue run every TODO_INTERVAL seconds. It remembers the last complete queue run and will just return if we get triggered before last queue run plus TODO_INTERVAL seconds. If we get triggered before TODO_INTERVAL seconds it will schedule a forced queue run at last complete queue run plus TODO_INTERVAL seconds to not miss the new additions to the queue. TODO_INTERVAL can also be set in the control file todointerval. The control file takes precedence over the environment variable. If TODO_INTERVAL=0, TODO_INTERVAL="" or a value less than zero, todo-proc silently uses 10 secs as the value for TODO_INTERVAL.

If todo-proc receives a HUP signal, it will reread locals, todointerval, virtualdomains, envnoathost, conf-syncdir, and conf-fsync.

qmail-send can run delivery and todo processing in detached mode on receipt of SIGUSR1. In detached mode, qmail-send processes the existing local and remote queue present at the time of the receipt of SIGUSR1 and schedules delivery jobs not yet started, for existing local/remote queue. Once there are no existing jobs, qmail-send instructs todo-proc to start sending new jobs. Meanwhile todo-proc continues to process new mails and classify them as local or remote, but new jobs are not sent to qmail-send for delivery. One can issue the signal SIGUSR2 to enter the normal attached mode, where mail delivery gets scheduled immediately after todo processing by having todo-proc start communicating with qmail-send. SIGUSR1 should be used if qmail-send is unable to cope with high injection rates. One may issue SIGUSR1 if you want to pre-process the incoming emails but schedule delivery later on receipt of SIGUSR2. If there are no pending deliveries and SIGUSR1 is issued, only todo-proc enters detached mode. In this mode, todo-proc continues to classifies message but doesn't send the jobs to qmail-send until SIGUSR1 is sent to qmail-send. With indimail-mta's multi-queue architecture, this feature will most probably never be required. But the feature is there in case you are running with a single queue and you experience high injection causing sluggish delivery.

If the environment variable USE_FSYNC is set, then todo-proc writess all data to disk ("flushes") all modified in-core data of (i.e., modified buffer cache pages for) the new message to the disk device (or other permanent storage device) so that all changed information can be retrieved even if the system crashes or is rebooted. This includes writing through or flushing a disk cache if present. The call blocks until the device reports that the transfer has completed. This is done for the info and mess files. This can also be set by using conf-fsync control file.

If the environment variable USE_SYNCDIR is enabled, qmail-send forces BSD style directory syncing. This can also be set by using conf-syncdir control file.

todo-proc can be configured to use a queue with a different split subdirectory value than compile time value of 151. This can be done by setting the CONFSPLIT envrionment variable. Additionally, it can process a queue created with todo, intd with subdirectory split instead of without any split. This can be done by setting the BIGTODO environment variable.

todo-proc uses qmail-clean(8) to cleanup message in intd, todo queue subdirectory after a successful delivery. todo-proc also does cleanup of files left in case of a crash. See the section on Cleanups in indimail-mta-internals(7). Any left over file not accessed for more than 1296000 seconds are removed. The default of 129600 seconds can be changed by setting OSSIFIED environment variable. If setting OSSIFIED, ensure that it is larger than the value of DEATH environment variable used by qmail-queue.

The control files conf-syncdir, conf-fsync take precedence over the environment variable counterparts. If the control conf-fsync, conf-syncdir are present, qmail-send will additionally set or unset the environment variables USE_FSYNC, USE_SYNCDIR. This feature is exploited by qmail-local(8). The fsync(2) system call is used for doing this.

todo-proc runs as qmails user, qmail group.

OPTIONS

-s
This implies todo-proc will use static queue mode described previously.

-d
This implements dynamic queue mode described previously. See multi-queue(7) for a complete overview.

-c
When using dynamic queue mode, this enables compatability mode with the traditional method of using the lock/trigger fifo in the queue directory. This allows qmail-queue running in non-dynamic mode to trigger scan of the todo directory. This method can be used when the system has qmail-queue clients from qmail or netqmail on the system. Using compatability mode doesn't give you the full performance benefits when system is configured to use POSIX IPC for dynamic queues.

INTERNALS

Communication between qmail-send and todo-proc

todo-proc -> qmail-send D[LRB]<mesgid>\0 Start delivery for new message with id <messid>. the character L, R or B defines the type of delivery, local, remote or both respectively. L<string>\0 Dump string to the logger without adding additional \n or similar.

qmail-send -> todo-proc H Got a SIGHUP reread /etc/indimail/control/locals and /etc/indimail/control/virtualdomains X Quit ASAP.

todo-proc sends "\0" terminated messages whereas qmail-send sends just one character to todo-proc.

CREDITS

todo-proc borrows its basic design from the ext-todo patch by Claudio Jeker <jeker@n-r-g.com> and Andre Oppermann <opi@nrg4u.com> (c) 1998,1999,2000,2001,2002 Internet Business Solutions Ltd.

SEE ALSO

qmail-queue(8), qmail-start(8), qscheduler(8), multi-queue(7), qmail-send(8), qmail-lspawn(8), qmail-rspawn(8), svc(8), indimail-mta-internals(7), mq_open(3) fsync(2)

Clone this wiki locally