From owner-freebsd-bugs@freebsd.org Sat Mar 16 01:12:34 2019 Return-Path: Delivered-To: freebsd-bugs@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 99CCE1537C84 for ; Sat, 16 Mar 2019 01:12:34 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mailman.ysv.freebsd.org (mailman.ysv.freebsd.org [IPv6:2001:1900:2254:206a::50:5]) by mx1.freebsd.org (Postfix) with ESMTP id 2AF518D1B0 for ; Sat, 16 Mar 2019 01:12:34 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: by mailman.ysv.freebsd.org (Postfix) id DC9801537C7F; Sat, 16 Mar 2019 01:12:33 +0000 (UTC) Delivered-To: bugs@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B93571537C7E for ; Sat, 16 Mar 2019 01:12:33 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.ysv.freebsd.org (mxrelay.ysv.freebsd.org [IPv6:2001:1900:2254:206a::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.ysv.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 548168D1AC for ; Sat, 16 Mar 2019 01:12:33 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2001:1900:2254:206a::16:76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.ysv.freebsd.org (Postfix) with ESMTPS id 978681CADE for ; Sat, 16 Mar 2019 01:12:32 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.118]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id x2G1CWSZ046862 for ; Sat, 16 Mar 2019 01:12:32 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id x2G1CWpe046861 for bugs@FreeBSD.org; Sat, 16 Mar 2019 01:12:32 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 236564] Anticongestion function does not work as is expected. Date: Sat, 16 Mar 2019 01:12:31 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: bin X-Bugzilla-Version: CURRENT X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Some People X-Bugzilla-Who: yasu@utahime.org X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: bugs@FreeBSD.org X-Bugzilla-Flags: mfc-stable11? mfc-stable12? X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter flagtypes.name attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 16 Mar 2019 01:12:34 -0000 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D236564 Bug ID: 236564 Summary: Anticongestion function does not work as is expected. Product: Base System Version: CURRENT Hardware: Any OS: Any Status: New Severity: Affects Some People Priority: --- Component: bin Assignee: bugs@FreeBSD.org Reporter: yasu@utahime.org Flags: mfc-stable11?, mfc-stable12? Created attachment 202893 --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=3D202893&action= =3Dedit Patch file I. Summary Under some conditions anticongestion function in /etc/default/periodic.conf does not work as is expected II. Backgroup Anticongestion function is defined in /etc/default/periodic.conf. If I understand correctly the purpose of it is to insert random sleep just one t= ime through all periodic scripts even if it is called more than once. III. Problem Description Currently (at base r345186) /etc/periodic/daily/480.leapfile-ntpd is a only periodic script on base system that calls anticongestion function. So let me assume following situation. * There is no /etc/weekly.local. * There is no periodic script under /usr/local/etc/periodic/security. * There is only one periodic script 123-foo under /usr/local/etc/periodic/weekly. * 123-foo calls anticongestion function in it. Then what happens when 'periodic weekly' is executed from cron? Periodic(8) executes scripts with following order. 1. /etc/periodic/weekly/310.locate 2. /etc/periodic/weekly/320.whatis 3. /etc/periodic/weekly/340.noid 4. /etc/periodic/weekly/450.status-security 4.01. /etc/periodic/security/100.chksetuid 4.02. /etc/periodic/security/110.neggrpperm 4.03. /etc/periodic/security/200.chkmounts 4.04. /etc/periodic/security/300.chkuid0 4.05. /etc/periodic/security/400.passwdless 4.06. /etc/periodic/security/410.logincheck 4.07. /etc/periodic/security/500.ipfwdenied 4.08. /etc/periodic/security/510.ipfdenied 4.09. /etc/periodic/security/520.pfdenied 4.10. /etc/periodic/security/550.ipfwlimit 4.11. /etc/periodic/security/610.ipf6denied 4.12. /etc/periodic/security/700.kernelmsg 4.13. /etc/periodic/security/800.loginfail 4.14. /etc/periodic/security/900.tcpwrap 5. /etc/periodic/weekly/999.local 6. /usr/local/etc/periodic/weekly/123-foo As is explained above no script under /etc/periodic/weekly and /etc/periodic/security calls anticongestion function. So expected behavior = is that anticongestion function is called and random sleep insterted at step 6. But it is different from real one. What really happens is that anticongesti= on function is called at step 6 but random sleep is not inserted. IV. Source of Problem The source of problem is that periodic(8) is executed twice when 'periodic weekly' is executed from cron. That is, first when it is executed from cron, and next when /etc/periodic/weekly/450.status-security is executed. There is following codes at line 79-81 of /usr/sbin/periodic. ---------------------------------------------------------------------- if [ -z "$PERIODIC_ANTICONGESTION_FILE" ] ; then export PERIODIC_ANTICONGESTION_FILE=3D`mktemp ${TMPDIR:-/tmp}/periodic.anticongestion.XXXXXXXXXX` fi ---------------------------------------------------------------------- And there is following code at last line of /usr/sbin/periodic. ---------------------------------------------------------------------- rm -f $PERIODIC_ANTICONGESTION_FILE ---------------------------------------------------------------------- Anticongestion function is defined in /etc/default/periodic.conf as followi= ng. ---------------------------------------------------------------------- # Sleep for a random amount of time in order to mitigate the thunde= ring # herd problem of multiple hosts running periodic simultaneously. # Will not sleep when used interactively. # Will sleep at most once per invocation of periodic anticongestion() { [ -n "$PERIODIC_IS_INTERACTIVE" ] && return if [ -f "$PERIODIC_ANTICONGESTION_FILE" ]; then rm -f $PERIODIC_ANTICONGESTION_FILE sleep `jot -r 1 0 ${anticongestion_sleeptime}` fi } ---------------------------------------------------------------------- So what really happens is as following. a. 'periodic weekly' is executed from cron and master process of periodic(8= ) is created.=20 b. Because PERIODIC_ANTICONGESTION_FILE is not set in master process, tempo= rary file is created, its path is set as value of PERIODIC_ANTICONGESTION_FILE a= nd PERIODIC_ANTICONGESTION_FILE is exported. c. /etc/periodic/weekly/450.status-security is executed and slave process of periodic(8) is created d. Because PERIODIC_ANTICONGESTION_FILE is already set in slave process, another temporary file is not created and the value of PERIODIC_ANTICONGESTION_FILE is not changed. e. At the end of slave process temporary file created at step b is removed. f. Slave process exits and return to master process. g. /usr/local/etc/periodic/weekly/123-foo is executed and anticongestion function is called. h. Because temporary file created at step b is already removed at step e, random sleep is not inserted. In this way anticongestion function does not work as is expected. V. Solution By applying attached patch the problem is fixed. --=20 You are receiving this mail because: You are the assignee for the bug.=