[squid-dev] [PATCH] Create PID file ASAP

Eduard Bagdasaryan eduard.bagdasaryan at measurement-factory.com
Mon May 15 08:34:26 UTC 2017


Hello,


With this fix applied, PID file is created right after configuration
finalization, before the allocation for any shared memory segments.

Late PID file creation allowed N+1 concurrent Squid instances to create
the same set of shared segments (overwriting each other segments),
resulting in extremely confusing havoc because the N instances would
later lose the race for the PID file (or some other critical resource)
creation and remove the segments. If that removal happened before a kid
of the single surviving instance started, that kid would fail to start
with open() errors in Segment.cc because the shared segment it tries to
open would be gone. Otherwise, that kid would fail to _restart_ after
any unrelated failures (possibly many days after the conflict), with
same errors, for the same reason.

Shared state corruption was also possible if different kids (of the
winning instance) opened (and started using) segments created (and
initialized) by different instances.

Situations with N+1 concurrent Squid instances are not uncommon because
many Squid service management scripts (or manual admin commands!)
* do not check whether another Squid is already running and/or
* incorrectly assume that "squid -z" does not daemonize.

This change finally makes starting N+1 Squid instances safe (AFAIK).

Also made daemonized and non-daemonized Squid create the PID file at the
same startup stage, reducing inconsistencies between the two modes.

This patch should be applied after applying PID file creation atomicity fix:
http://lists.squid-cache.org/pipermail/squid-dev/2017-May/008584.html


Regards,

Eduard.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: SQUID-286-correct-pid-file-creation-timing-t2.patch
Type: text/x-patch
Size: 9830 bytes
Desc: not available
URL: <http://lists.squid-cache.org/pipermail/squid-dev/attachments/20170515/be3b5353/attachment.bin>


More information about the squid-dev mailing list