Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1X7sG8-0005jk-Ea for pgsql-admin@arkaria.postgresql.org; Thu, 17 Jul 2014 20:26:32 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1X7sG7-0007PS-Tm for pgsql-admin@arkaria.postgresql.org; Thu, 17 Jul 2014 20:26:31 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1X7sG5-0007PJ-Dv for pgsql-admin@postgresql.org; Thu, 17 Jul 2014 20:26:29 +0000 Received: from mail-ig0-x235.google.com ([2607:f8b0:4001:c05::235]) by makus.postgresql.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1X7sG0-0003rN-NG for pgsql-admin@postgresql.org; Thu, 17 Jul 2014 20:26:27 +0000 Received: by mail-ig0-f181.google.com with SMTP id h3so3605085igd.2 for ; Thu, 17 Jul 2014 13:26:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type; bh=UxmubTQzBpiIluErPwqI8X/7Jp0jRbGVxzG4jzutk5s=; b=O5lw5LVAx4qNyCTGvt06jlLQYooqieha9wGWhdC7j8aqwsF5PjeevrfpEANmOmPxz3 PBsGDHCQZURFTvpRpMuD1vR8bI/V3v7RoffIg6Yk6/pAm9NKCDM48m4Uov+uOpnJyu9k YY15usZgLdB7RLYyZYJ/48XI4UVg9W8ALkTdKWNqmxSxsTofi5ICR1gK33i51jCU9LRF GlZi3jw88aSQjSvgHPuVb/cU3lN3tFYnof63yi5UIm7AB5QZxrl/GjopsmAAiOXQ/Gc7 ddgnI6GW8J1t47hXkYPnI7dJrJrnefhf6lfmGr/dA1fHzc71uG++4X99gzOIoi4skI/c 6ZFQ== X-Received: by 10.50.18.76 with SMTP id u12mr1136213igd.13.1405628782917; Thu, 17 Jul 2014 13:26:22 -0700 (PDT) Received: from [192.168.254.2] (h77.89.102.166.static.ip.windstream.net. [166.102.89.77]) by mx.google.com with ESMTPSA id gb7sm9616081igd.16.2014.07.17.13.26.21 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 17 Jul 2014 13:26:22 -0700 (PDT) Message-ID: <53C83168.2060504@gmail.com> Date: Thu, 17 Jul 2014 16:26:16 -0400 From: John Scalia User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 MIME-Version: 1.0 To: Scott Whitney , "pgsql-admin@postgresql.org" Subject: Re: Trying to recover a corrupted database References: <53C81F98.9070405@gmail.com> <984033755.512124.1405624595840.JavaMail.zimbra@mail.int.journyx.com> <53C822FF.4070301@gmail.com> <2135893762.512398.1405625418721.JavaMail.zimbra@mail.int.journyx.com> <53C826AF.9050001@gmail.com> <924415881.513241.1405627090106.JavaMail.zimbra@mail.int.journyx.com> <53C82CA0.6050607@gmail.com> <954714428.513417.1405627765439.JavaMail.zimbra@mail.int.journyx.com> In-Reply-To: <954714428.513417.1405627765439.JavaMail.zimbra@mail.int.journyx.com> Content-Type: multipart/alternative; boundary="------------060504010506020906040701" X-Pg-Spam-Score: -2.0 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-admin Precedence: bulk Sender: pgsql-admin-owner@postgresql.org This is a multi-part message in MIME format. --------------060504010506020906040701 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Well, nothing to lose, so I did a touch on pg_clog/0CDE and at least the error changed. Now it says: DETAIL: Could not read from file "pg_clog/0CDE" at offset 98304: Success. But I don't understand why it says Success? On 7/17/2014 4:09 PM, Scott Whitney wrote: > OOhhh...IIRC I think that I created the clog file as a zero byte file to get around that. It was _absolutely_ a step of last resort. I would be certain that you have a backup > that can get you back to this point at least before proceeding. > > http://kb.parallels.com/en/6067 > > ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ > > I was attempting to do that with one table that I know is broken, but I can't get anything from it in a select. All I get no matter what is: > > ERROR: could not access status of transaction 3706060803 > DETAIL: Could not open file "pg_clog/OCDE": No such file or directory > > I think the pg_clog files are transaction journal files that tell the Db why a record is or is not in the table, but I'm not certain. I just wish there was a pg_resetclog > executable like there is for the pg_xlog segments. > > On 7/17/2014 3:58 PM, Scott Whitney wrote: > > Yeah. I know the feeling, man. What I ended up doing was "select * from" until I found the broken one then jumped down into groups of thousands of records and basically > "Newtoned" it down until I found the affected data. > > It sucked. A lot. > > ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ > > Well, we already have the schema in a canned file. So, we wouldn't need to do a pg_dump for the schema, and I can get into the database using psql obviously. That's > how I produced the setting from pg_settings. But, I really don't want to have to go through 150K+ records to find the multiple broken ones, if I don't have to do so. > I'm just hoping for a faster way. > > On 7/17/2014 3:30 PM, Scott Whitney wrote: > > Well, at this point, let me let the big brains answer your main question on the thread and tell you what _I_ did when I got into a similar situation. > > a) pg_dump --schema-only > db.structure > b) From here it was a lot of select * from table until I found the broken one(s) and I worked around the actual bad data by offset/limit on the selects on the > busted tables. > > It took me several hours, but it did work (for me). > > That's assuming you can even psql to the db in the first place when the postmaster is running. > > ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ > > We're only working with a single database on this system, and yes, I attempted a pg_dump earlier today on just one single table - it failed (I know pg_dump > and pg_basebackup use different mechanisms.) Mind you it's a large table with 154,000 rows in it. The overall database is somewhere around 43GB. > > On 7/17/2014 3:16 PM, Scott Whitney wrote: > > a) How many databases do you have? > b) Have you tried to pg_dump the database(s) to see if that succeeds? > > If you _can_ pg_dump (which you might or might not be able to do), you could re-init the cluster and restore. > > ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ > > Hi all, > > You may have seen my post from yesterday about our production database getting corrupted. Well, this morning we brought the system down to single user > and ran an fsck which did > report some drive errors. We repeated until no additional errors were reported. Then, we brought the system back to multi-user status and ran a > successful pg_basebackup on the > broken database. Since then we restarted the database and a ps -ef result looks like: > > /usr/pgsql-9.2/bin/postmaster -D /opt/datacenter -o -c zero_damaged_pages=true -i -N 384 -p 5431 > > After the Db started up, we ran a VACUUM FULL ANALYZE which ran for about 3 hours, but the database is still showing the same type of errors in its > log: invalid page header in > block 29718... etc. What disturbed me a little, is that I don't think the zero_damaged_pages got applied. Checking the pg_settings table, we got: > > select name, setting, boot_val, reset_val from pg_settings where name = 'zero_damaged_pages'; > name | setting | boot_val | reset_val > --------------------------------------------------------------------------------- > zero_damaged_pages | on | off | on > > Now, my colleague ran this after he tried running some operations again after I told him how to set zero_damaged_pages again. He swears that that it > was on when the first VACUUM > FULL ANALYZE was run, but I'm not as sure. Plus, I don't understand why the boot_val shows as off. In any event, as we're still getting log errors > like before, I don't really know > what to try next other than rerunning the VACUUM FULL again. Help? > -- > Jay > > > > -- > Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-admin > > > > > > > --------------060504010506020906040701 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit Well, nothing to lose, so I did a touch on pg_clog/0CDE and at least the error changed. Now it says:

DETAIL: Could not read from file "pg_clog/0CDE" at offset 98304: Success.

But I don't understand why it says Success?

On 7/17/2014 4:09 PM, Scott Whitney wrote:
OOhhh...IIRC I think that I created the clog file as a zero byte file to get around that. It was _absolutely_ a step of last resort. I would be certain that you have a backup that can get you back to this point at least before proceeding.



I was attempting to do that with one table that I know is broken, but I can't get anything from it in a select. All I get no matter what is:

ERROR: could not access status of transaction 3706060803
DETAIL: Could not open file "pg_clog/OCDE": No such file or directory

I think the pg_clog files are transaction journal files that tell the Db why a record is or is not in the table, but I'm not certain. I just wish there was a pg_resetclog executable like there is for the pg_xlog segments.

On 7/17/2014 3:58 PM, Scott Whitney wrote:
Yeah. I know the feeling, man. What I ended up doing was "select * from" until I found the broken one then jumped down into groups of thousands of records and basically "Newtoned" it down until I found the affected data.

It sucked. A lot.


Well, we already have the schema in a canned file. So, we wouldn't need to do a pg_dump for the schema, and I can get into the database using psql obviously. That's how I produced the setting from pg_settings. But, I really don't want to have to go through 150K+ records to find the multiple broken ones, if I don't have to do so. I'm just hoping for a faster way.

On 7/17/2014 3:30 PM, Scott Whitney wrote:
Well, at this point, let me let the big brains answer your main question on the thread and tell you what _I_ did when I got into a similar situation.

a) pg_dump --schema-only <database name>   >  db.structure
b) From here it was a lot of select * from table until I found the broken one(s) and I worked around the actual bad data by offset/limit on the selects on the busted tables.

It took me several hours, but it did work (for me).

That's assuming you can even psql to the db in the first place when the postmaster is running.


We're only working with a single database on this system, and yes, I attempted a pg_dump earlier today on just one single table - it failed (I know pg_dump and pg_basebackup use different mechanisms.) Mind you it's a large table with 154,000 rows in it. The overall database is somewhere around 43GB.

On 7/17/2014 3:16 PM, Scott Whitney wrote:
a) How many databases do you have?
b) Have you tried to pg_dump the database(s) to see if that succeeds?

If you _can_ pg_dump (which you might or might not be able to do), you could re-init the cluster and restore.


Hi all,

You may have seen my post from yesterday about our production database getting corrupted. Well, this morning we brought the system down to single user and ran an fsck which did
report some drive errors. We repeated until no additional errors were reported. Then, we brought the system back to multi-user status and ran a successful pg_basebackup on the
broken database. Since then we restarted the database and a ps -ef result looks like:

/usr/pgsql-9.2/bin/postmaster -D /opt/datacenter -o -c zero_damaged_pages=true -i -N 384 -p 5431

After the Db started up, we ran a VACUUM FULL ANALYZE which ran for about 3 hours, but the database is still showing the same type of errors in its log: invalid page header in
block 29718... etc. What disturbed me a little, is that I don't think the zero_damaged_pages got applied. Checking the pg_settings table, we got:

select name, setting, boot_val, reset_val from pg_settings where name = 'zero_damaged_pages';
                   name             |  setting  |  boot_val  | reset_val
---------------------------------------------------------------------------------
  zero_damaged_pages  |  on          | off              | on

Now, my colleague ran this after he tried running some operations again after I told him how to set zero_damaged_pages again. He swears that that it was on when the first VACUUM
FULL ANALYZE was run, but I'm not as sure. Plus, I don't understand why the boot_val shows as off. In any event, as we're still getting log errors like before, I don't really know
what to try next other than rerunning the VACUUM FULL again. Help?
--
Jay



--
Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin







--------------060504010506020906040701--