[squid-dev] SMP scaling in no_daemon mode?
Andreas Weigel
andreas.weigel at securepoint.de
Fri Jun 16 12:14:14 UTC 2017
Hi Amos,
> It is explicitly adding a regression in a very necessary behaviour for
> startup sequences running what is effectively "squid --foreground -z
> && squid". We will regress to the state of having race conditions as
> multiple independent sets of workers are spawned and collide with each
> others /dev/shm and whether or not the disk cache is formatted before
> Squid starts accepting client connections.
Correct me if I am wrong, but the current --foreground option makes the
"main process" waits for the termination of it's only child (not its
grand children), which is the daemonized master process (main.cc:1789;
WaitForAnyPid finally calls waitpid(-1, &status, 0) or wait3(&status, 0,
NULL), which is equivalent).
With the patch, instead of spawning a daemon and waiting for it to
finish, we just run the master process and wait for it to finish. In
both cases, the master process is responsible for making sure that it
only exits after the last child has exited. If this would not be the
case, the WaitForAnyPid() call in the unpatched version would do nothing
to prevent the master process exiting while its children are still
running. I do not see the regression here, but probably I am missing
something. I would even argue that the situation has improved, because
before it was at least possible, albeit improbable, that the
"master-forking" process is terminated by some signal while its master
child (and its worker grand chidren) were still running.
> The original notes wording (and --foreground design) was intended to
> be clear that in that made a Squid SMP-enabled instance operate as a
> consistent / atomic whole. **No background parts still operating after
> the main process exit()'s**.
I am convinced this is still the case with --foreground in an even more
accurate way, see above.
> Also, there are (or will be) installations containing "squid
> --foreground -N " due to the way some OS provide default options
> (using the new --foreground by default) and allow admin to extend them
> in a separate config file (usually with -N hacks from legacy installs).
> - the updated documentation implies that --foreground actively
> creates workers. Which will leave anyone with that config confused
> about what happens if they are both required (--foreground "and
> creates worker kids") and prohibited (-N). Yet Squid runs with nary a
> message about problems.
The behavior has not changed in that regard, only the wording. The two
options are incompatible and have been so before the patch. There is a
DBG_CRITICAL message stating that --foreground has no effect with -N. I
introduced a hint that -N is incompatible with --foreground in usage(),
but was convinced by Alex that it is probably better to explain those in
the documentation and not with the -h option. We can still discuss if a
better description can be found.
Kind Regards,
Andreas
--
Mit freundlichem Gruß / Best regards,
Andreas Weigel
UTM Backend Developer
Securepoint GmbH
Salzstrasse 1
D-21335 Lüneburg
https://www.securepoint.de
Tel.: +49(0)413124010
Fax: +49(0)4131240118
Geschäftsführer: Lutz Hausmann, Claudia Hausmann
Amtsgericht Lüneburg HRB 1776
USt.-ID-Nr.: DE 188 528 597
More information about the squid-dev
mailing list