From owner-freebsd-stable@FreeBSD.ORG Tue Apr 28 13:19:52 2015 Return-Path: Delivered-To: freebsd-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id CF79D372 for ; Tue, 28 Apr 2015 13:19:52 +0000 (UTC) Received: from gromit.dlib.vt.edu (gromit.dlib.vt.edu [128.173.126.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "gromit.dlib.vt.edu", Issuer "Chumby Certificate Authority" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id A4F541C2E for ; Tue, 28 Apr 2015 13:19:52 +0000 (UTC) Received: from pmather.lib.vt.edu (pmather.lib.vt.edu [128.173.126.193]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by gromit.dlib.vt.edu (Postfix) with ESMTPSA id 279215B0; Tue, 28 Apr 2015 09:11:52 -0400 (EDT) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2098\)) Subject: Re: protecting some processes from out-of-swap killer From: Paul Mather In-Reply-To: Date: Tue, 28 Apr 2015 09:11:51 -0400 Cc: freebsd-stable@freebsd.org Content-Transfer-Encoding: quoted-printable Message-Id: <95EED247-A571-43A4-9FAA-822118B5B8F1@gromit.dlib.vt.edu> References: <20150425104336.GD13141@ivaldir.etoilebsd.net> To: Ronald Klop X-Mailer: Apple Mail (2.2098) X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 28 Apr 2015 13:19:52 -0000 On Apr 28, 2015, at 5:51 AM, Ronald Klop wrote: > On Sat, 25 Apr 2015 13:15:32 +0200, Dmitry Morozovsky = wrote: >=20 >> On Sat, 25 Apr 2015, Baptiste Daroussin wrote: >>=20 >>> > However, sometimes postgres processes got killed by 'out of swap = space'. >>> > I suppose the source of problem could be that VSZ size of postgres = processes >>> > (8-9 G) is bigger than swap congigured (4G). >>> > >>> > Is there any way to prevent this, besides reallocating space for = swap? >>>=20 >>> protect(1) ? >>=20 >> Of course. I really do not understand how google hides the man page = from me. >>=20 >> Thanks, and sorry fot the noise. >>=20 >=20 >=20 > The OS trying to kill a process is probably not what you want. So when = you protect(1) postgres the OS will kill another process, which I hope = is not running without reason. > My advice would be to > - or increase your swap space > - or tune postgresql to use less memory > - or limit tmpfs (tmpfs uses swap if RAM is short) > - or tune zfs to use less memory That is good advice, although I do think "protect" has its place for = preventing unforeseen accidents as mentioned above. I believe it's good = to be able to designate certain processes as more valuable than others = if you know that to be the case. A case in point: We have an Omeka instance on a fairly low-resource = system. Omeka uses ImageMagick to generate thumbnails for items added = to collections. In one case, we had a very large TIFF file added, who, = when having a thumbnail generated, caused its thumbnail-generating = process to consume large amounts of memory and swap. When swap was = exhausted, the OS decided it needed to kill off something and settled = upon Apache (under which Omeka runs), causing Omeka to stop running. In = other times, the out-of-swap killer has chosen to kill the SSH daemon, = making it harder subsequently to access the box and fix problems. Being able to protect httpd---or even just sshd---served as a handy = safety belt after that happened. :-) I guess the proper way to address this would be to set limits on Apache = or the thumbnail generation so it doesn't go hog wild in the future... Cheers, Paul.