Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 1FAF5632B23 for ; Thu, 8 Jul 2010 04:37:56 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 15453-03 for ; Thu, 8 Jul 2010 07:37:47 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from isis.morrow.me.uk (isis.morrow.me.uk [204.109.63.142]) by mail.postgresql.org (Postfix) with ESMTP id 37EF9633190 for ; Thu, 8 Jul 2010 04:37:46 -0300 (ADT) Received: (qmail 78417 invoked from network); 8 Jul 2010 07:43:43 +0000 Received: from host81-158-161-2.range81-158.btcentralplus.com (HELO osiris.mauzo.dyndns.org) (mauzo@81.158.161.2) by isis.morrow.me.uk with AES256-SHA encrypted SMTP; 8 Jul 2010 07:43:43 +0000 Received: (qmail 23317 invoked by uid 1001); 8 Jul 2010 08:37:42 +0100 Date: Thu, 8 Jul 2010 08:37:42 +0100 From: Ben Morrow To: johnf@jfcomputer.com, pgsql-sql@postgresql.org Subject: Re: strangest thing happened Message-ID: <20100708073742.GA23191@osiris.mauzo.dyndns.org> References: <201007071259.03294.johnf@jfcomputer.com> <20100707204244.GB28181@rice.edu> <4C34FC50.6070203@magwerks.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <201007071541.27248.johnf@jfcomputer.com> X-Newsgroups: pgsql.sql Organization: Who, me? User-Agent: Mutt/1.5.20 (2009-06-14) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-0.011 tagged_above=-5 required=5 tests=BAYES_20=-0.001, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201007/43 X-Sequence-Number: 34356 Quoth johnf@jfcomputer.com (John): > On Wednesday 07 July 2010 03:14:40 pm Justin Graf wrote: > > I would be looking at the log files for the Inserts into that table as a > > means to track down what is the cause.  If there are no log files or > > don't have enough detail, crank up the logging level and wait for it to > > happen again??? > > > That is scary - let it happen again???? I'm not keeping enough info in the > log. I actually turned off most of the info the log files are gathering > because the system has been running for 6-7 months without an issue. I just > got a call around noon telling me something was going wrong. That's when I > discovered the sequences were the wrong values. I'm sure there has to be > some sort of real explanation - but I don't know what it is. There are several possible causes: - Something somewhere is inserting values directly into the serial columns, without using the sequence. This can be prevented by REVOKEing INSERT and UPDATE on the relevant columns for all users. If this causes problems anywhere in your app, those are good places to start looking for bugs. - Something somewhere is manipulating the sequence. This can be prevented by REVOKEing UPDATE on all sequences for all users. You may need some additional GRANTs of USAGE on sequences if parts of the app were relying on UPDATE to call nextval(). Obviously if your app routinely drops and creates tables you will need to arrange for these permissions to be applied every time. - The database has become corrupted, perhaps by a badly-done backup and restore. (I would not expect taking a backup alone to cause corruption, but if the backup isn't done right the backed-up copy may be corrupt.) Have you done a restore recently? - Something I haven't thought of :). - A bug in Pg. While this is *extremely* unlikely, it must be mentioned as a possibility. Ben