Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 0C6701337BD3 for ; Thu, 31 Mar 2011 05:07:08 -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 11129-01 for ; Thu, 31 Mar 2011 08:06:58 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from exprod7og126.obsmtp.com (exprod7og126.obsmtp.com [64.18.2.206]) by mail.postgresql.org (Postfix) with ESMTP id 859771337BA8 for ; Thu, 31 Mar 2011 05:06:56 -0300 (ADT) Received: from source ([209.85.215.176]) (using TLSv1) by exprod7ob126.postini.com ([64.18.6.12]) with SMTP ID DSNKTZQ2H8Re4Dx0UkylI/UO3sTDg8bamYYG@postini.com; Thu, 31 Mar 2011 01:06:57 PDT Received: by eya28 with SMTP id 28so620199eya.7 for ; Thu, 31 Mar 2011 01:06:54 -0700 (PDT) Received: by 10.14.11.83 with SMTP id 59mr1306479eew.39.1301558338334; Thu, 31 Mar 2011 00:58:58 -0700 (PDT) Received: from [192.168.1.183] (dsl-hkibrasgw2-ff7ac300-240.dhcp.inet.fi [88.195.122.240]) by mx.google.com with ESMTPS id b52sm564649eei.1.2011.03.31.00.58.56 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 31 Mar 2011 00:58:57 -0700 (PDT) Message-ID: <4D94343F.6030302@enterprisedb.com> Date: Thu, 31 Mar 2011 10:58:55 +0300 From: Heikki Linnakangas User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; fi-FI; rv:1.9.1.16) Gecko/20110307 Icedove/3.0.11 MIME-Version: 1.0 To: Jon Nelson CC: pgsql-bugs@postgresql.org Subject: Re: backend for database 'A' crashes/is killed -> corrupt index in database 'B' References: In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-5 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201103/401 X-Sequence-Number: 29911 On 30.03.2011 21:06, Jon Nelson wrote: > The short version is that if a postgresql backend is killed (by the Linux > OOM handler, or kill -9, etc...) while operations are > taking place in a *different* backend, corruption is introduced in the other > backend. I don't want to say it happens 100% of the time, but it happens > every time I test. >... > > Here is how I am reproducing the problem: > > 1. Open a psql connection to database A. It may remain idle. > 2. Wait for an automated process to connect to database B and start > operations. These operations > 3. kill -9 the backend for the psql connection to database A. > > Then I observe the backends all shutting down and postgresql entering > recovery mode, which succeeds. > Subsequent operations on other databases appear fine, but not for > database B: An index on one of the tables in database B is corrupted. > It is always the > same index. > > 2011-03-30 14:51:32 UTC LOG: server process (PID 3871) was terminated by > signal 9: Killed > 2011-03-30 14:51:32 UTC LOG: terminating any other active server > processes > 2011-03-30 14:51:32 UTC WARNING: terminating connection because of crash > of another server process > 2011-03-30 14:51:32 UTC DETAIL: The postmaster has commanded this server > process to roll back the current transaction and exit, because another > server process exited abnormally and possibly corrupted shared memory. > 2011-03-30 14:51:32 UTC HINT: In a moment you should be able to reconnect > to the database and repeat your command. > 2011-03-30 14:51:32 UTC databaseB databaseB WARNING: terminating connection > because of crash of another server process > 2011-03-30 14:51:32 UTC databaseB databaseB DETAIL: The postmaster has > commanded this server process to roll back the current transaction and exit, > because another server process exited abnormally and possibly corrupted > shared memory. > 2011-03-30 14:51:32 UTC databaseB databaseB HINT: In a moment you should be > able to reconnect to the database and repeat your command. > 2011-03-30 14:51:32 UTC LOG: all server processes terminated; > reinitializing > 2011-03-30 14:51:32 UTC LOG: database system was interrupted; last known > up at 2011-03-30 14:46:50 UTC > 2011-03-30 14:51:32 UTC databaseB databaseB FATAL: the database system is > in recovery mode > 2011-03-30 14:51:32 UTC LOG: database system was not properly shut down; > automatic recovery in progress > 2011-03-30 14:51:32 UTC LOG: redo starts at 301/1D328E40 > 2011-03-30 14:51:33 UTC databaseB databaseB FATAL: the database system is > in recovery mode > 2011-03-30 14:51:34 UTC LOG: record with zero length at 301/1EA08608 > 2011-03-30 14:51:34 UTC LOG: redo done at 301/1EA08558 > 2011-03-30 14:51:34 UTC LOG: last completed transaction was at log time > 2011-03-30 14:51:31.257997+00 > 2011-03-30 14:51:37 UTC LOG: autovacuum launcher started > 2011-03-30 14:51:37 UTC LOG: database system is ready to accept > connections > 2011-03-30 14:52:05 UTC databaseB databaseB ERROR: index "" > contains unexpected zero page at block 0 > 2011-03-30 14:52:05 UTC databaseB databaseB HINT: Please REINDEX it. > > What's more, I can execute a 'DELETE from tableB' (where tableB is the > table that is the one with the troublesome index) without error, but > when I try to *insert* that is when I get a problem. The index is a > standard btree index. The DELETE statement has no where clause. Can you provide a self-contained test script to reproduce this? Is the corruption always the same, ie. "unexpected zero page at block 0" ? > My interpretation of these values is that the drives themselves have > their write caches disabled. Ok. It doesn't look like a hardware issue, as there's no OS crash involved. -- Heikki Linnakangas EnterpriseDB http://www.enterprisedb.com