Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 50348475A6F for ; Tue, 13 Aug 2002 17:02:59 -0400 (EDT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 9DAFC4759B0 for ; Tue, 13 Aug 2002 17:02:58 -0400 (EDT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.5/8.12.5) with ESMTP id g7DL2lVk001103; Tue, 13 Aug 2002 17:02:48 -0400 (EDT) To: "Thomas O'Connell" Cc: pgsql-admin@postgresql.org Subject: Re: performance tuning: shared_buffers, sort_mem; swap In-reply-to: References: <27214.1029257785@sss.pgh.pa.us> Comments: In-reply-to "Thomas O'Connell" message dated "Tue, 13 Aug 2002 13:20:16 -0500" Date: Tue, 13 Aug 2002 17:02:47 -0400 Message-ID: <1101.1029272567@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200208/168 X-Sequence-Number: 5283 "Thomas O'Connell" writes: > In article <27214.1029257785@sss.pgh.pa.us>, > tgl@sss.pgh.pa.us (Tom Lane) wrote: >> Uh, which error exactly? AFAIK all the shared-memory-related messages >> would only come out at postmaster startup, not during peak load. The >> system is designed to ensure that those resources are all reserved >> during postmaster start. > Sorry, I should've included the whole error in the first place: > "IpcMemoryCreate: shmget(key=5432001, size=72368128, 03600) failed: > Invalid argument Hmm. That's definitely a startup-time error. The only way that code could be executed later than postmaster startup is if you suffer a database crash and the postmaster is trying to reinitialize the system with a fresh shared-memory arena. That would say that this isn't your primary problem, but a consequence of a crash that'd already occurred. I am curious why you'd get "Invalid argument" (EINVAL), as presumably these are the same arguments that the kernel accepted on the previous cycle of life. But that's probably not the issue to focus on. My bet for the cause of the database crash is the same as Bruce's: the Linux kernel is known to "kill -9" processes at random when it gets under sufficiently heavy memory pressure. If it happens to select a database backend to kill, the postmaster will interpret the backend's unexpected exit as a crash, and will force a database restart. Perhaps when the postmaster tries to reallocate the shmem segment a few milliseconds later, the kernel still thinks it's under load and rejects a shmem request that it'd normally have accepted. (That last bit is just speculation though.) Possible solutions: (a) buy more RAM and/or increase available swap space (I'm not sure whether more swap, without more physical RAM, actually helps; anyone know?); (b) reduce peak load by reducing max_connections and/or scaling back your other servers; (c) switch to another OS --- I don't think the *BSD kernels have this brain-damaged idea about how to cope with low memory... regards, tom lane