Re: Fixing OID directory names after a fsck

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Richard Neill <postgresql(at)richardneill(dot)org>
Cc: pgsql-admin(at)postgresql(dot)org
Subject: Re: Fixing OID directory names after a fsck
Date: 2017-09-11 22:39:17
Message-ID: 8125.1505169557@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Richard Neill <postgresql(at)richardneill(dot)org> writes:
>> This is unlikely to work unless you can also recover the pg_clog
>> contents, which unfortunately might be pretty difficult to identify.

> I can't find it. However, the failure was in the middle of the night,
> and I think there's a pretty decent chance that postgres was idle at the
> time - there was "probably" no transaction in progress, and the WAL
> should have committed.

That's all fine, but it only means that the right transactions would
be marked committed in pg_clog. There's no very good reason to suppose
that that marking has propagated back to the heap tuples in all cases.

Actually though, I suspect a big chunk of your problem is that even
tuples that are hinted committed will seem to be "in the future".
You'd need to also recover pg_control, or at least reset it to something
approximating the current XID counter, before stuff is likely to look
sane.

If you don't have pg_control, you might be able to dig around in the most
recently modified tables and guess at the current XID by looking for the
largest XIDs you can find.

But, TBH, this is getting way past what you're likely to successfully
pull off if you've never done it before. There are folks who do PG
data recovery professionally [not me], and if your data is worth money
to you, you'd be best off hiring someone who's done this before. If
it's not, chalk this up to a learning experience, and set up a better
backup system.

regards, tom lane

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message James Lawrence 2017-09-12 04:20:56 Re: pg_dump making schema output consistent.
Previous Message Richard Neill 2017-09-11 22:27:08 Re: Fixing OID directory names after a fsck